serverless-plugins icon indicating copy to clipboard operation
serverless-plugins copied to clipboard

serverless-offline-sqs doesn't work on a port other than the default (9324)

Open gfpacheco opened this issue 3 years ago • 3 comments

I happen to be working on multiple microservices that depend on their own SQS queue. But if I change the port of the ElasticMQ instance the server doesn't start up:

  Unknown Endpoint ---------------------------------------

  UnknownEndpoint: Inaccessible host: `localhost'. This service may not be available in the `us-west-2' region.
      at Request.ENOTFOUND_ERROR (/Users/guilhermepacheco/Workspace/ae/brainbase/vault-backend/node_modules/aws-sdk/lib/event_listeners.js:507:46)
      at Request.callListeners (/Users/guilhermepacheco/Workspace/ae/brainbase/vault-backend/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
      at Request.emit (/Users/guilhermepacheco/Workspace/ae/brainbase/vault-backend/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
      at Request.emit (/Users/guilhermepacheco/Workspace/ae/brainbase/vault-backend/node_modules/aws-sdk/lib/request.js:688:14)
      at ClientRequest.error (/Users/guilhermepacheco/Workspace/ae/brainbase/vault-backend/node_modules/aws-sdk/lib/event_listeners.js:339:22)
      at ClientRequest.<anonymous> (/Users/guilhermepacheco/Workspace/ae/brainbase/vault-backend/node_modules/aws-sdk/lib/http/node.js:96:19)
      at ClientRequest.emit (events.js:315:20)
      at ClientRequest.EventEmitter.emit (domain.js:486:12)
      at Socket.socketErrorListener (_http_client.js:469:9)
      at Socket.emit (events.js:315:20)
      at Socket.EventEmitter.emit (domain.js:486:12)
      at emitErrorNT (internal/streams/destroy.js:106:8)
      at emitErrorCloseNT (internal/streams/destroy.js:74:3)
      at processTicksAndRejections (internal/process/task_queues.js:80:21)

If I change the port on my docker compose file and my custom config to be 9324 everything works just fine, any other port breaks the server.

gfpacheco avatar Dec 30 '20 21:12 gfpacheco

I have the same error with the default port number but also inside a docker container

custom config in serverless.yml

  serverless-offline-sqs:
    autoCreate: true    # create queue if not exists
    endpoint: http://sqs:9324
    accessKeyId: root
    secretAccessKey: root

I have my serverless project in 1 container, and the elasticmq in different container (called sqs), both on the same docker network using docker-compose.

docker-compose ps
  Name                Command                  State                    Ports              
-------------------------------------------------------------------------------------------
project    /entrypoint.sh                   Exit 1                                         
sqs        /sbin/tini -- /opt/docker/ ...   Up             0.0.0.0:9324->9324/tcp, 9325/tcp

I still seem to get the error

UnknownEndpoint: Inaccessible host: `localhost'. This service may not be available in the `eu-west-1' region.
      at Request.ENOTFOUND_ERROR (/app/node_modules/serverless-offline-sqs/node_modules/aws-sdk/lib/event_listeners.js:507:46)
      at Request.callListeners (/app/node_modules/serverless-offline-sqs/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
      at Request.emit (/app/node_modules/serverless-offline-sqs/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
      at Request.emit (/app/node_modules/serverless-offline-sqs/node_modules/aws-sdk/lib/request.js:688:14)
      at ClientRequest.error (/app/node_modules/serverless-offline-sqs/node_modules/aws-sdk/lib/event_listeners.js:339:22)
      at ClientRequest.<anonymous> (/app/node_modules/serverless-offline-sqs/node_modules/aws-sdk/lib/http/node.js:96:19)
      at ClientRequest.emit (events.js:315:20)
      at ClientRequest.EventEmitter.emit (domain.js:467:12)
      at Socket.socketErrorListener (_http_client.js:469:9)
      at Socket.emit (events.js:315:20)
      at Socket.EventEmitter.emit (domain.js:467:12)
      at emitErrorNT (internal/streams/destroy.js:106:8)
      at emitErrorCloseNT (internal/streams/destroy.js:74:3)
      at processTicksAndRejections (internal/process/task_queues.js:80:21)

iainvm avatar Jan 08 '21 17:01 iainvm

I have the same issue, is there any solution to make this work with docker? Using from host machine it's working.

esteveslima avatar Apr 18 '21 05:04 esteveslima

To make it works, you must run an ElasticMQ container: docker run -p 9324:9324 -p 9325:9325 softwaremill/elasticmq-native

wellermiranda avatar Feb 02 '22 22:02 wellermiranda