-
-
Notifications
You must be signed in to change notification settings - Fork 798
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
ECONNREFUSED
when sending websocket message to client when using sls offline
#924
Comments
I am having same issue. |
I was able to fix the issue, not sure it is with serverless but in your code https://github.com/bryanvaz/sls-websocket-demo/blob/b1c614c4db1adfedff92d399d2a6fedf407d366a/src/connector/apigateway.connector.js#L9 if you point endpoint to Bare in mind your config might be correct in aws, you only need to do that in local development |
Thanks @jimishshah, but the point of the WS endpoint for @dnalborczyk I noticed you've been patching most of the WS server code in Dec. Did you ever get the WS server to send messages to the client locally? That functionality is critical for CI-based integration and behaviour tests (Realized this is actually the most important use case last week when I spent 3 hrs digging through lamda logs.) |
@bryanvaz You said it well but still figured i'd share my current work around when using websockets locally with const gatewayApi = new ApiGatewayManagementApi({
apiVersion: '2018-11-29',
// `sls offline` has [issue](https://github.com/dherault/serverless-offline/issues/924) where it can't send
// the message back to the websocket client (using ws://localhost:3001).
// TODO: look for a fix to this hack
endpoint: process.env.IS_LOCAL_SERVERLESS_MODE ? `http://localhost:3001` : `${event.requestContext.domainName}/${event.requestContext.stage}`,
}); |
@ChrisTowles Nice now I get it (@jimishshah now I get what you were trying to say) |
I used a slightly different proces.env.IS_OFFLINE const endpoint = process.env.IS_OFFLINE ? 'http://localhost:3001' : |
Take note that the |
Bug Report
Current Behavior
When trying to send a Websocket message to a local client using the standard
Aws.ApiGatewayManagementApi
connector inserverless-offline
, the connector's TCP connection to the client is refused. However this works fine when deployed to AWS.Tested on MacOS Catalina 10.15.3.
See https://github.com/bryanvaz/sls-websocket-demo for demo of the issue.
Not sure if this is a weird MacOS firewall issue or something else someone has encountered before. I can't seem to figure out why the initial connection is successful, but sending messages fails.
Detailed Error Message
Sample Code
See https://github.com/bryanvaz/sls-websocket-demo for simple demo and full description of the issue.
Expected behavior/code
The serverless-server should respond with a
{"action":"PING", "value":"PONG"}
message to the client.Environment
serverless
version: v1.66.0serverless-offline
version: v5.12.1 (also happens with v6.0.0-alpha.68)node.js
version: v12.16.1OS
: macOS 10.15.3The text was updated successfully, but these errors were encountered: