Skip to content
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

ConnectionId for API Gateway requests is missing #76

Closed
AntonRamashko opened this issue Feb 14, 2019 · 3 comments
Closed

ConnectionId for API Gateway requests is missing #76

AntonRamashko opened this issue Feb 14, 2019 · 3 comments

Comments

@AntonRamashko
Copy link

As in code example from Node.js from here connectionId is used to manage WebSocket sessions:

exports.handler = function(event, context, callback) {
var deleteParams = {
    TableName: process.env.TABLE_NAME,
    Key: {
     connectionId: { S: event.requestContext.connectionId }
    }
};

Meanwhile Java class com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent.ProxyRequestContext doesn't have such field.

@PatrykGala
Copy link

I've used workaround:

public class ConnectHandler implements RequestHandler<Map<String, Object>, ApiGatewayResponse> {
    private static final Logger LOG = LogManager.getLogger(ConnectHandler.class);

    @Override
    public ApiGatewayResponse handleRequest(Map<String, Object> input, Context context) {
        String connectionId = extractConnectionId(input);
        LOG.info("connectionid: {}", connectionId);
        return ApiGatewayResponse.ok(connectionId);
    }

    private String extractConnectionId(Map<String, Object> input) {
        Map<String, Object> requestContext = (Map<String, Object>) input.get("requestContext");
        return (String) requestContext.get("connectionId");
    }
}

lucasam pushed a commit to lucasam/aws-lambda-java-libs that referenced this issue Jul 28, 2019
 * extendedRequestId
 * requestTime
 * requestTimeEpoch
 * domainName
 * protocol
 * connectionId
 * routeKey
 * messageId
 * eventType
 * messageDirection
 * connectedAt
 Fixes issues
 aws#88
 aws#76
 aws#71
 aws#41
@lucasam
Copy link

lucasam commented Aug 1, 2019

I believe this PR #92 fixes this issue.
A new class https://github.com/aws/aws-lambda-java-libs/blob/master/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2ProxyRequestEvent.java is created to handle APIGatewayV2 parameters

Still not present at version 2.6.0. Needs to be built from sources

@carlzogh
Copy link
Contributor

@lucasam APIGatewayV2ProxyRequestEvent was added in version 2.2.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants