-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lambda.invoke() doesn't send client context #1388
Comments
It looks like you need to put the data you wish to send under the key var AWS = require('aws-sdk');
var la = new AWS.Lambda({ region: 'us-west-2' });
var ctx = {
custom: { foo: 'bar' },
client: { snap: ['crackle', 'pop']},
env: { fizz: 'buzz' },
};
la.invoke({
FunctionName: 'contextPrinter',
ClientContext: AWS.util.base64.encode(JSON.stringify(ctx)),
InvocationType: 'RequestResponse',
Payload: JSON.stringify({ baz: 'quux' })
}, function (err, data) { return console.log(err, data); }); and the following lambda: def lambda_handler(event, context):
print("context", context.client_context)
print("client", ', '.join(i for i in dir(context.client_context.client) if not i.startswith('__')))
print("custom", context.client_context.custom)
print("env", context.client_context.env) I get the following log output:
The client context contains data about the client, but data under the |
Thanks Jason, I can verify that that works now. This should be clarified in the documentation - how do we get an update request into the doc team? |
The |
I can confirm @smber1's observation, not getting passed along when running as Personally I'm finding the documentation around this to be quite sparse, it seems like clientContext is really intended to be used with their mobile / ad SDKs and not well supported otherwise. |
Don't know if there's an update on this by this time. Would love to pass some context from an ending function call into a chained invocation to maintain state until long-running processing job is complete. |
Im using the latest Javascript SDK and trying to send some client context from a browser app to a Lambda function. Here's a snippet of the sending end:
This call completes fine and even returns the data I want it to. However the Client Context is lost.
On the server side, I have a Python Lambda function with the usual method signature:
Upon execution the 'ctx' object has three attributes: client, custom, env all of which are
None
.Where is my 'client context'?
I'm pretty sure it's being sent correctly on the client side, as if you pass a string that isn't correct, then you get a message 'Client context must be a valid Base64-encoded JSON object'.
The text was updated successfully, but these errors were encountered: