a year 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
a year ago
a864dd2b-2b49-4eee-b5b2-627b3c084d43
a year ago
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

a year ago
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"}a year ago
When I test with my local docker container, it all seems to work correctly
a year ago
Happy to provide more details if needed
a year ago
is it listening on :: ?
a year ago
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=localhostWhich is the resolved address for
--http --http.addr=lavish-liberation.railway.internal --ws --ws.addr=lavish-liberation.railway.internal
a year ago
you don't want to listen on its IPv6 address
a year ago
please have it listen on ::
a year ago
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=localhosta year ago
It has the exact same issue
a year ago
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 specifieda year ago

a year ago
hey now it's responding
a year ago
now what host is it talking about
a year ago
Thast's a good question
a year ago
I initially had that issue, so I tried resolving to the internal network address
a year ago
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.0a year ago
is there anything in the deploy logs that could help?
a year ago
Nope, I see nothing in the logs when I get that error
a year ago
If I look at the http logs, it shows a 403
a year ago

a year ago
so what even is sonic node?
a year ago
It's an RPC node for a blockchain
a year ago
by having it on railway it increases the speed of our operation by 5-6x (when it works <:kek:885396556520493056> )
a year ago
I don't think our public proxy supports RPC
a year ago
it's strictly http
a year ago
But the RPC works over http, it's just a post request
a year ago
does it? try the TCP proxy instead
a year ago
on it
a year ago
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 peera year ago
the TCP proxy is pointing to the correct port right?
a year ago
As far as I understand I send the RPC requests over HTTP POST or websocket with the payload as part of the body
a year ago
yes

a year ago
hmm well I'm not sure what to tell you, I'm not familiar with the software
a year ago
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
a year ago
Exact same setup as on Railway
a year ago
what would you typically see when you open the domain in the browser?
a year ago
nothing
a year ago
The only way to see if it's working is by sending a post request with a simple method
a year ago
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"}'a year ago
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"}a year ago
maybe it was never designed to work behind a proxy
a year ago
Maybe
a year ago
It's one source software, I'm happy to review the source if needed
a year ago
What would be a pointer that it's not designed to work behind a proxy?
a year ago
In case you're curious, this is the source https://github.com/Fantom-foundation/Sonic/tree/v2.0.1
a year ago
find out what triggers "invalid host specified" to be returned, and don't return that error lol
a year ago
<:kek:885396556520493056>
a year ago
Alright, thank you for your time
a year ago
i know we for sure pass through the Host value unmodified
a year ago
Knowing that it's not a configuration error is a good start
a year ago
I'll post my findings here
a year ago
sounds good, wish I could have helped more!
a year ago
@Brody Found a solution, turns out I had to enable a vhosts flag https://github.com/ethereum/go-ethereum/issues/16526#issuecomment-992480651
a year ago
It's working now <:pog:925010410518749194>
a year ago
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
a year ago
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
a year ago
but not idea 😄
a year 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?
a year ago
I don't really see it gracfully shutting down

a year ago
the application would need to properly handle sigterm
a year ago
you are using a volume right? and making sure data is actually being written to said volume
a year ago
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
a year ago
yeah we don't send ctrl + c haha, sigterm is a standardized way to tell an app to shut down
a year ago
I know, I just expected both to send the same signal
a year ago
Feel free to close the ticket btw, thanks for your help!
a year ago
this is what it'd look like

a year ago
yeah it's probably just listening in the wrong signal, sounds like an easy pr
a year ago
yeah ctrl + c is sigint
a year ago
stopNodeSig := make(chan os.Signal, 1)
signal.Notify(stopNodeSig, syscall.SIGINT, syscall.SIGTERM)
defer signal.Stop(stopNodeSig)
startFreeDiskSpaceMonitor(ctx, stopNodeSig, stack.InstanceDir())
<-stopNodeSiga year ago
looks like an easy PR indeed
a year ago
I don't know much go but that looks like it should listen to SIGTERMs too
a year ago
I know go and it looks like that will do what you need to
a year ago
as long as 3 seconds is enough, but if it's not you can always up that time via railway
a year ago
It should be more than enough, takes like under 100ms locally
a year ago
Just in case, what's the parameter to up that in Railway?
a year ago
perfect
a year ago
RAILWAY_DEPLOYMENT_DRAINING_SECONDS
a year ago
Thanks!
a year ago
Tweaking this worked, skill issue on my end as per usual
a year ago
happy to hear that
a year ago
!s
Status changed to Solved brody • 11 months ago