5 months ago
Hi,
I'm running a docker container that exposed an HTTP server. I am trying to connect to it both through internal networking and external through creating a proxy and I can't get any of them working.
I can run this same container locally and communicate with it just fine. Not sure what I'm doing wrong here.
This is the repo I'm running https://github.com/0xFluffyBeard/sonic-node-docker
0 Replies
I get this error when trying to access it externally
curl -X POST https://sonic-node-production.up.railway.app -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":0,"method":"eth_blockNumber"}'
-------
{"status":"error","code":502,"message":"Application failed to respond","request_id":"lkW-NHaVTzaLfux9H3rXOA_3500563535"}%
And a 403 when trying to access it from within the local network
curl -X POST http://localhost:18545 -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":0,"method":"eth_blockNumber"}'
-------
{"jsonrpc":"2.0","id":0,"result":"0x55151"}
5 months ago
is it listening on ::
?
Right now it's listening on
INFO [12-12|20:28:09.013] HTTP server started endpoint=[fd12:e16:9f4f:0:4000:a:9ded:4c28]:18545 auth=false prefix= cors= vhosts=localhost
Which is the resolved address for
--http --http.addr=lavish-liberation.railway.internal --ws --ws.addr=lavish-liberation.railway.internal
4 months ago
you don't want to listen on its IPv6 address
4 months ago
please have it listen on ::
I've just created a new one listening on ::
INFO [12-13|07:38:38.806] HTTP server started endpoint=[::]:18545 auth=false prefix= cors= vhosts=localhost
curl -X POST https://sonic-node-docker-production.up.railway.app -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":0,"method":"eth_blockNumber"}'
-------
invalid host specified
4 months ago
hey now it's responding
4 months ago
now what host is it talking about
I initially had that issue, so I tried resolving to the internal network address
Not sure how relevant it is, but I'm setting the following env variables
RUN_CMD_ARGS=--http --http.addr=0.0.0.0 --ws --ws.addr=0.0.0.0
4 months ago
is there anything in the deploy logs that could help?
4 months ago
so what even is sonic node?
by having it on railway it increases the speed of our operation by 5-6x (when it works <:kek:885396556520493056> )
4 months ago
I don't think our public proxy supports RPC
4 months ago
it's strictly http
4 months ago
does it? try the TCP proxy instead
Tried both http and https, got error on both
curl -v -X POST https://junction.proxy.rlwy.net:29067 -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":0,"method":"eth_blockNumber"}'
Note: Unnecessary use of -X or --request, POST is already inferred.
* Host junction.proxy.rlwy.net:29067 was resolved.
* IPv6: (none)
* IPv4: 35.214.222.137
* Trying 35.214.222.137:29067...
* Connected to junction.proxy.rlwy.net (35.214.222.137) port 29067
* ALPN: curl offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
* CAfile: /etc/ssl/cert.pem
* CApath: none
* Recv failure: Connection reset by peer
* LibreSSL/3.3.6: error:02FFF036:system library:func(4095):Connection reset by peer
* Closing connection
curl: (35) Recv failure: Connection reset by peer
❯ curl -v -X POST http://junction.proxy.rlwy.net:29067 -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":0,"method":"eth_blockNumber"}'
Note: Unnecessary use of -X or --request, POST is already inferred.
* Host junction.proxy.rlwy.net:29067 was resolved.
* IPv6: (none)
* IPv4: 35.214.222.137
* Trying 35.214.222.137:29067...
* Connected to junction.proxy.rlwy.net (35.214.222.137) port 29067
> POST / HTTP/1.1
> Host: junction.proxy.rlwy.net:29067
> User-Agent: curl/8.7.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 51
>
* upload completely sent off: 51 bytes
* Recv failure: Connection reset by peer
* Closing connection
curl: (56) Recv failure: Connection reset by peer
4 months ago
the TCP proxy is pointing to the correct port right?
As far as I understand I send the RPC requests over HTTP POST or websocket with the payload as part of the body
4 months ago
hmm well I'm not sure what to tell you, I'm not familiar with the software
Not sure what else to try myself, I have it running locally without issues, I set it up on a VPS last night to test and it also runs just fine
4 months ago
what would you typically see when you open the domain in the browser?
The only way to see if it's working is by sending a post request with a simple method
This would be the simplest one
curl -X POST http://localhost:18545 -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":0,"method":"eth_blockNumber"}'
This is what the result looks like
❯ curl -X POST http://localhost:18545 -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":0,"method":"eth_blockNumber"}'
{"jsonrpc":"2.0","id":0,"result":"0x583f7"}
4 months ago
maybe it was never designed to work behind a proxy
In case you're curious, this is the source https://github.com/Fantom-foundation/Sonic/tree/v2.0.1
4 months ago
find out what triggers "invalid host specified" to be returned, and don't return that error lol
4 months ago
i know we for sure pass through the Host value unmodified
4 months ago
sounds good, wish I could have helped more!
@Brody Found a solution, turns out I had to enable a vhosts flag https://github.com/ethereum/go-ethereum/issues/16526#issuecomment-992480651
Another question on the topic, is there any way to gracefully shutdown a deployment? When making changes and re-deploying, it seems to just kill the container which corrupts the databse and makes it so we have to wipe the volume and re-index the entire blockchain, which is ~2h
It's not the end of the world since we can just keep two deployments open at all times and use one of them as a failover
4 months ago
old deployments are always gracefully shut down.
when the system goes to remove a deployment it is sent sigterm and then waits 3 seconds before force killing, is that 3 seconds not enough?
4 months ago
the application would need to properly handle sigterm
4 months ago
you are using a volume right? and making sure data is actually being written to said volume
Looks like it's an implementation issue, when shutting down through a ctrl + c
on the console it does gracefully shutdown, but I can't seem to be able to do the same on Docker
4 months ago
yeah we don't send ctrl + c haha, sigterm is a standardized way to tell an app to shut down
4 months ago
yeah it's probably just listening in the wrong signal, sounds like an easy pr
4 months ago
yeah ctrl + c is sigint
stopNodeSig := make(chan os.Signal, 1)
signal.Notify(stopNodeSig, syscall.SIGINT, syscall.SIGTERM)
defer signal.Stop(stopNodeSig)
startFreeDiskSpaceMonitor(ctx, stopNodeSig, stack.InstanceDir())
<-stopNodeSig
4 months ago
I know go and it looks like that will do what you need to
4 months ago
as long as 3 seconds is enough, but if it's not you can always up that time via railway
4 months ago
perfect
4 months ago
RAILWAY_DEPLOYMENT_DRAINING_SECONDS
4 months ago
happy to hear that
4 months ago
!s
Status changed to Solved brody • 4 months ago