Skip to content
This repository has been archived by the owner on Aug 26, 2020. It is now read-only.

Why random external port does not work? #6

Closed
shouze opened this issue Apr 8, 2016 · 11 comments
Closed

Why random external port does not work? #6

shouze opened this issue Apr 8, 2016 · 11 comments

Comments

@shouze
Copy link
Contributor

shouze commented Apr 8, 2016

If I run event store that way:

$ docker run --name eventstore-node -it -p 2113 -p 1113 eventstore/eventstore

instead of:

$ docker run --name eventstore-node -it -p 2113:2113 -p 1113:1113 eventstore/eventstore

TCP & HTTP ports will be dynamically attributed by docker, but if I then open the url:

$ open http://$(docker-machine ip):$(docker inspect --type container --format '{{ (index (index .NetworkSettings.Ports "2113/tcp") 0).HostPort }}' eventstore)

The connection can't be established!

@shouze
Copy link
Contributor Author

shouze commented Apr 8, 2016

Ho, and I guessed it was some IPv6 missbinding joke... but in fact no:

$ docker exec -it eventstore netstat -nptl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:1113            0.0.0.0:*               LISTEN      1/eventstored
tcp        0      0 0.0.0.0:2113            0.0.0.0:*               LISTEN      1/eventstored

So looks like it's not either docker or Linux tcp/ip fault, there's something special in the way eventstored bind its ports?

@hayley-jean
Copy link
Member

Hi

Could you please curl the node's stats url and see if that works?

curl -i http://<docker-machine-ip>:<port>/stats 

@hayley-jean
Copy link
Member

The reason I ask you to do this is because the url you are trying to open is for the admin UI, which does not work when the ports between docker and the host don't match up. This is because the UI redirects you to the external-http port that's set in configuration (2113 by default) when you try to open it from a different port.

@shouze
Copy link
Contributor Author

shouze commented Apr 8, 2016

@hayley-jean yes in fact I'm redirected if point to / path:

curl -i "http://"$(docker-machine ip)":"$(docker inspect --type container --format '{{ (index (index .NetworkSettings.Ports "2113/tcp") 0).HostPort }}' eventstore)"/"         18:30:53  default
HTTP/1.1 302 Found
Access-Control-Allow-Methods: GET, OPTIONS
Access-Control-Allow-Headers: Content-Type, X-Requested-With, X-Forwarded-Host, X-PINGOTHER, Authorization, ES-LongPoll, ES-ExpectedVersion, ES-EventId, ES-EventType, ES-RequiresMaster, ES-HardDelete, ES-ResolveLinkTo, ES-ExpectedVersion
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Location, ES-Position
Location: http://192.168.99.100:2113/web/index.html
Content-Type: text/plain; charset=utf-8
Server: Mono-HTTPAPI/1.0
Date: Fri, 08 Apr 2016 16:31:00 GMT
Content-Length: 5
Keep-Alive: timeout=15,max=100

Moved

/stats if working without any redirection:

curl -i "http://"$(docker-machine ip)":"$(docker inspect --type container --format '{{ (index (index .NetworkSettings.Ports "2113/tcp") 0).HostPort }}' eventstore)"/stats"
HTTP/1.1 200 OK
Access-Control-Allow-Methods: GET, OPTIONS
Access-Control-Allow-Headers: Content-Type, X-Requested-With, X-Forwarded-Host, X-PINGOTHER, Authorization, ES-LongPoll, ES-ExpectedVersion, ES-EventId, ES-EventType, ES-RequiresMaster, ES-HardDelete, ES-ResolveLinkTo, ES-ExpectedVersion
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Location, ES-Position
Cache-Control: max-age=1, public
Vary: Accept
Content-Type: application/json; charset=utf-8
Server: Mono-HTTPAPI/1.0
Date: Fri, 08 Apr 2016 16:33:04 GMT
Content-Length: 12024
Keep-Alive: timeout=15,max=100

{
  "proc": {
    "startTime": "2016-04-08T13:23:57.0000000Z",
    "id": 1,
    "mem": 99536896,
    "cpu": 0.0,
    "cpuScaled": 0.0,
    "threadsCount": 0,
    "contentionsRate": 0.0,
    "thrownExceptionsRate": 0.0,
    "tcp": {
      "connections": 0,
      "receivingSpeed": 0.0,
      "sendingSpeed": 0.0,
      "inSend": 0,
      "measureTime": "00:00:18.1100800",
      "pendingReceived": 0,
      "pendingSend": 0,
      "receivedBytesSinceLastRun": 0,
      "receivedBytesTotal": 0,
      "sentBytesSinceLastRun": 0,
      "sentBytesTotal": 0
    },
    "gc": {
      "allocationSpeed": 0.0,
      "gen0ItemsCount": 0,
      "gen0Size": 0,
      "gen1ItemsCount": 0,
      "gen1Size": 0,
      "gen2ItemsCount": 0,
      "gen2Size": 0,
      "largeHeapSize": 0,
      "timeInGc": 0.0,
      "totalBytesInHeaps": 0
    }
  },
  "sys": {
    "cpu": 7.55379,
    "freeMem": 150528000,
    "drive": {
      "/var/lib/eventstore": {
        "availableBytes": 15569285120,
        "totalBytes": 19507089408,
        "usage": "20%",
        "usedBytes": 3937804288
      }
    }
  },
  "es": {
    "checksum": 4165457,
    "checksumNonFlushed": 4165457,
    "queue": {
      "mainQueue": {
        "queueName": "MainQueue",
        "groupName": "",
        "avgItemsPerSecond": 13,
        "avgProcessingTime": 0.02513125,
        "currentIdleTime": "0:00:00:00.6394198",
        "currentItemProcessingTime": null,
        "idleTimePercent": 99.966651049282476,
        "length": 0,
        "lengthCurrentTryPeak": 3,
        "lengthLifetimePeak": 10,
        "totalItemsProcessed": 101475,
        "inProgressMessage": "<none>",
        "lastProcessedMessage": "Schedule"
      },
      "monitoringQueue": {
        "queueName": "MonitoringQueue",
        "groupName": "",
        "avgItemsPerSecond": 0,
        "avgProcessingTime": 0.0,
        "currentIdleTime": null,
        "currentItemProcessingTime": "0:00:00:00.3030952",
        "idleTimePercent": 98.324564313484274,
        "length": 0,
        "lengthCurrentTryPeak": 0,
        "lengthLifetimePeak": 2,
        "totalItemsProcessed": 14,
        "inProgressMessage": "GetFreshStats",
        "lastProcessedMessage": "GetFreshStats"
      },
      "projection Core #0": {
        "queueName": "Projection Core #0",
        "groupName": "Projection Core",
        "avgItemsPerSecond": 0,
        "avgProcessingTime": 0.20747142857142856,
        "currentIdleTime": "0:00:00:18.0755544",
        "currentItemProcessingTime": null,
        "idleTimePercent": 99.99197259289987,
        "length": 0,
        "lengthCurrentTryPeak": 2,
        "lengthLifetimePeak": 9,
        "totalItemsProcessed": 2104,
        "inProgressMessage": "<none>",
        "lastProcessedMessage": "EventReaderIdle"
      },
      "projection Core #1": {
        "queueName": "Projection Core #1",
        "groupName": "Projection Core",
        "avgItemsPerSecond": 0,
        "avgProcessingTime": 0.072628571428571417,
        "currentIdleTime": "0:00:00:18.0751062",
        "currentItemProcessingTime": null,
        "idleTimePercent": 99.997189688906687,
        "length": 0,
        "lengthCurrentTryPeak": 1,
        "lengthLifetimePeak": 9,
        "totalItemsProcessed": 2079,
        "inProgressMessage": "<none>",
        "lastProcessedMessage": "EventReaderIdle"
      },
      "projection Core #2": {
        "queueName": "Projection Core #2",
        "groupName": "Projection Core",
        "avgItemsPerSecond": 0,
        "avgProcessingTime": 0.15348571428571428,
        "currentIdleTime": "0:00:00:18.0755387",
        "currentItemProcessingTime": null,
        "idleTimePercent": 99.994061531882664,
        "length": 0,
        "lengthCurrentTryPeak": 2,
        "lengthLifetimePeak": 9,
        "totalItemsProcessed": 2072,
        "inProgressMessage": "<none>",
        "lastProcessedMessage": "EventReaderIdle"
      },
      "projections Master": {
        "queueName": "Projections Master",
        "groupName": "",
        "avgItemsPerSecond": 19,
        "avgProcessingTime": 0.014503072625698324,
        "currentIdleTime": "0:00:00:00.0764715",
        "currentItemProcessingTime": null,
        "idleTimePercent": 99.971274463595137,
        "length": 0,
        "lengthCurrentTryPeak": 0,
        "lengthLifetimePeak": 9,
        "totalItemsProcessed": 154393,
        "inProgressMessage": "<none>",
        "lastProcessedMessage": "Schedule"
      },
      "storage Chaser": {
        "queueName": "Storage Chaser",
        "groupName": "",
        "avgItemsPerSecond": 10,
        "avgProcessingTime": 0.018446448087431695,
        "currentIdleTime": "0:00:00:00.0075074",
        "currentItemProcessingTime": null,
        "idleTimePercent": 99.981837452479752,
        "length": 0,
        "lengthCurrentTryPeak": 0,
        "lengthLifetimePeak": 0,
        "totalItemsProcessed": 78213,
        "inProgressMessage": "<none>",
        "lastProcessedMessage": "ChaserCheckpointFlush"
      },
      "storageReaderQueue #1": {
        "queueName": "StorageReaderQueue #1",
        "groupName": "StorageReaderQueue",
        "avgItemsPerSecond": 0,
        "avgProcessingTime": 0.088885714285714276,
        "currentIdleTime": "0:00:00:00.6395203",
        "currentItemProcessingTime": null,
        "idleTimePercent": 99.996562288594433,
        "length": 0,
        "lengthCurrentTryPeak": 0,
        "lengthLifetimePeak": 0,
        "totalItemsProcessed": 2462,
        "inProgressMessage": "<none>",
        "lastProcessedMessage": "ReadStreamEventsForward"
      },
      "storageReaderQueue #2": {
        "queueName": "StorageReaderQueue #2",
        "groupName": "StorageReaderQueue",
        "avgItemsPerSecond": 0,
        "avgProcessingTime": 0.067566666666666664,
        "currentIdleTime": "0:00:00:03.6460471",
        "currentItemProcessingTime": null,
        "idleTimePercent": 99.997760706065137,
        "length": 0,
        "lengthCurrentTryPeak": 0,
        "lengthLifetimePeak": 1,
        "totalItemsProcessed": 2461,
        "inProgressMessage": "<none>",
        "lastProcessedMessage": "ReadStreamEventsForward"
      },
      "storageReaderQueue #3": {
        "queueName": "StorageReaderQueue #3",
        "groupName": "StorageReaderQueue",
        "avgItemsPerSecond": 0,
        "avgProcessingTime": 0.17368333333333333,
        "currentIdleTime": "0:00:00:02.6424068",
        "currentItemProcessingTime": null,
        "idleTimePercent": 99.994241736532615,
        "length": 0,
        "lengthCurrentTryPeak": 0,
        "lengthLifetimePeak": 0,
        "totalItemsProcessed": 2461,
        "inProgressMessage": "<none>",
        "lastProcessedMessage": "ReadStreamEventsForward"
      },
      "storageReaderQueue #4": {
        "queueName": "StorageReaderQueue #4",
        "groupName": "StorageReaderQueue",
        "avgItemsPerSecond": 0,
        "avgProcessingTime": 0.13745,
        "currentIdleTime": "0:00:00:01.6407077",
        "currentItemProcessingTime": null,
        "idleTimePercent": 99.995442365144612,
        "length": 0,
        "lengthCurrentTryPeak": 0,
        "lengthLifetimePeak": 1,
        "totalItemsProcessed": 2461,
        "inProgressMessage": "<none>",
        "lastProcessedMessage": "ReadStreamEventsForward"
      },
      "storageWriterQueue": {
        "queueName": "StorageWriterQueue",
        "groupName": "",
        "avgItemsPerSecond": 0,
        "avgProcessingTime": 11.0902,
        "currentIdleTime": "0:00:00:18.0779318",
        "currentItemProcessingTime": null,
        "idleTimePercent": 99.93869607995974,
        "length": 0,
        "lengthCurrentTryPeak": 0,
        "lengthLifetimePeak": 2,
        "totalItemsProcessed": 313,
        "inProgressMessage": "<none>",
        "lastProcessedMessage": "WritePrepares"
      },
      "subscriptions": {
        "queueName": "Subscriptions",
        "groupName": "",
        "avgItemsPerSecond": 1,
        "avgProcessingTime": 0.013905263157894737,
        "currentIdleTime": "0:00:00:00.8139527",
        "currentItemProcessingTime": null,
        "idleTimePercent": 99.99854398905893,
        "length": 0,
        "lengthCurrentTryPeak": 0,
        "lengthLifetimePeak": 6,
        "totalItemsProcessed": 8115,
        "inProgressMessage": "<none>",
        "lastProcessedMessage": "CheckPollTimeout"
      },
      "timer": {
        "queueName": "Timer",
        "groupName": "",
        "avgItemsPerSecond": 32,
        "avgProcessingTime": 0.13935670103092782,
        "currentIdleTime": "0:00:00:00.0006571",
        "currentItemProcessingTime": null,
        "idleTimePercent": 99.547836739471208,
        "length": 9,
        "lengthCurrentTryPeak": 9,
        "lengthLifetimePeak": 10,
        "totalItemsProcessed": 250885,
        "inProgressMessage": "<none>",
        "lastProcessedMessage": "ExecuteScheduledTasks"
      },
      "worker #1": {
        "queueName": "Worker #1",
        "groupName": "Workers",
        "avgItemsPerSecond": 1,
        "avgProcessingTime": 0.029969230769230769,
        "currentIdleTime": "0:00:00:00.3031109",
        "currentItemProcessingTime": null,
        "idleTimePercent": 99.995690561414648,
        "length": 0,
        "lengthCurrentTryPeak": 0,
        "lengthLifetimePeak": 1,
        "totalItemsProcessed": 10915,
        "inProgressMessage": "<none>",
        "lastProcessedMessage": "AuthenticatedHttpRequestMessage"
      },
      "worker #2": {
        "queueName": "Worker #2",
        "groupName": "Workers",
        "avgItemsPerSecond": 1,
        "avgProcessingTime": 0.0192,
        "currentIdleTime": "0:00:00:00.9969058",
        "currentItemProcessingTime": null,
        "idleTimePercent": 99.997314063399315,
        "length": 0,
        "lengthCurrentTryPeak": 0,
        "lengthLifetimePeak": 1,
        "totalItemsProcessed": 10915,
        "inProgressMessage": "<none>",
        "lastProcessedMessage": "PurgeTimedOutRequests"
      },
      "worker #3": {
        "queueName": "Worker #3",
        "groupName": "Workers",
        "avgItemsPerSecond": 1,
        "avgProcessingTime": 0.012428,
        "currentIdleTime": "0:00:00:00.6398037",
        "currentItemProcessingTime": null,
        "idleTimePercent": 99.998273681845816,
        "length": 0,
        "lengthCurrentTryPeak": 0,
        "lengthLifetimePeak": 1,
        "totalItemsProcessed": 10915,
        "inProgressMessage": "<none>",
        "lastProcessedMessage": "IODispatcherDelayedMessage"
      },
      "worker #4": {
        "queueName": "Worker #4",
        "groupName": "Workers",
        "avgItemsPerSecond": 1,
        "avgProcessingTime": 0.015911538461538463,
        "currentIdleTime": "0:00:00:00.6395140",
        "currentItemProcessingTime": null,
        "idleTimePercent": 99.997722564549079,
        "length": 0,
        "lengthCurrentTryPeak": 0,
        "lengthLifetimePeak": 1,
        "totalItemsProcessed": 10914,
        "inProgressMessage": "<none>",
        "lastProcessedMessage": "ReadStreamEventsForwardCompleted"
      },
      "worker #5": {
        "queueName": "Worker #5",
        "groupName": "Workers",
        "avgItemsPerSecond": 1,
        "avgProcessingTime": 0.012361538461538462,
        "currentIdleTime": "0:00:00:00.3032140",
        "currentItemProcessingTime": null,
        "idleTimePercent": 99.998224484779428,
        "length": 0,
        "lengthCurrentTryPeak": 0,
        "lengthLifetimePeak": 1,
        "totalItemsProcessed": 10914,
        "inProgressMessage": "<none>",
        "lastProcessedMessage": "IncomingHttpRequestMessage"
      }
    },
    "writer": {
      "lastFlushSize": 16066,
      "lastFlushDelayMs": 10.9045,
      "meanFlushSize": 14167,
      "meanFlushDelayMs": 9.8155105442176875,
      "maxFlushSize": 16179,
      "maxFlushDelayMs": 91.0055,
      "queuedFlushMessages": 0
    },
    "readIndex": {
      "cachedRecord": 1300,
      "notCachedRecord": 0,
      "cachedStreamInfo": 27542,
      "notCachedStreamInfo": 78,
      "cachedTransInfo": 0,
      "notCachedTransInfo": 0
    }
  }
}

@hayley-jean
Copy link
Member

@shouze Thanks for checking that, that's what I expected.

The admin UI will not work when the ports are not the same. Atom feeds won't work either, as any links returned by ES will use port 2113, not the port you are binding to.

For an example of this, you can try

curl -i http://<docker-machine-ip>:<port>/streams/<stream-id> -H "accept:application/json"

In short, while it still works with dynamically assigned ports, you are better off making sure that the ports you bind to match the ones EventStore is using.

I will add a note about this in the readme on docker-hub

@gregoryyoung
Copy link

This could likely be supported by adding an override to the port

On Mon, Apr 11, 2016 at 9:58 AM, Hayley Campbell notifications@github.com
wrote:

@shouze https://github.com/shouze Thanks for checking that, that's what
I expected.

The admin UI will not work when the ports are not the same. Atom feeds
won't work either, as any links returned by ES will use port 2113, not the
port you are binding to.

For an example of this, you can try

curl -i http://:/streams/ -H "accept:application/json"

In short, while it still works with dynamically assigned ports, you are
better off making sure that the ports you bind to match the ones EventStore
is using.

I will add a note about this in the readme on docker-hub


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#6 (comment)

Studying for the Turing test

@shouze
Copy link
Contributor Author

shouze commented Apr 11, 2016

@gregoryyoung yes, for that we have to resolve at runtime just before eventstore start the port attributed dynamically by docker, it should come from the outside of the container, passed as an env var.

I'm not sure though this is so easy in docker, this is not the business of the containerised binary to know how port are mapped outside by design.

@dls314
Copy link

dls314 commented Mar 23, 2017

@gregoryyoung Do you mean that I could (correctly) use settings of ExtIp, ExtHttpPort, ExtTcpPort to make this scenario work?

@gregoryyoung
Copy link

gregoryyoung commented Mar 23, 2017 via email

@dls314
Copy link

dls314 commented Mar 23, 2017

As in use the *_ADVERTISE_AS settings in addition to the ones I mentioned above so that gossip is also corrected along with the UI and Feeds?

@arwinneil
Copy link

Hello,

This issue has been close due to management of Docker builds moving to EventStore/EventStore, and this repository is due to be archived. If you are still experiencing this issue, please re-open this issue in the new repository.

Thank you.

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

No branches or pull requests

5 participants