dherault / serverless-offline

Emulate AWS λ and API Gateway locally when developing your Serverless project
MIT License
5.16k stars 794 forks source link

Allow binding `websocketPort` to `port` #1799

Open cnuss opened 2 weeks ago

cnuss commented 2 weeks ago

Description

In the following serverless.yml configuration:

custom:
  serverless-offline:
    port: 3000
    websocketPort: 3000

The following error occurs at startup:

✖ Unexpected error while starting serverless-offline server on port 3000: { Error: listen EADDRINUSE: address already in use ::1:3000
      at Server.setupListenHandle [as _listen2] (node:net:1898:16)
      at listenInCluster (node:net:1946:12)
      at GetAddrInfoReqWrap.doListen [as callback] (node:net:2116:7)
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:111:8)
    code: 'EADDRINUSE',
    errno: -98,
    syscall: 'listen',
    address: '::1',
    port: 3000 }

Motivation and Context

In a lot of HTTP + Websocket services, the Websocket and HTTP server can share the same port since they are on different protocols.

This PR:

Finally:

How Has This Been Tested?

cnuss commented 2 weeks ago

hi @dherault and @DorianMazur could you take a look at this PR? Thanks!