Is it possible to get the IP address of an incoming websocket connection?

63 views
Skip to first unread message

untied

unread,
Oct 19, 2018, 6:45:45 PM10/19/18
to Crystal
My websocket server runs this way:

ws_hdl = WebSocketHandler.new do |ws|

   
# here we should determine somehow the IP address of an incoming connection

end

srv
= Server.new ws_hdl
srv
.listen("0.0.0.0", 8080)

Is it possible to obtain an IP address of the remote host?
It is required for logging and for security reasons as well.

Thanks in advance for any good advice!

Jack Thorne

unread,
Oct 22, 2018, 1:13:11 PM10/22/18
to Crystal
Looks like you have access to the request through the context.
I would print out all the request vars and see if there is anything in there.
Reply all
Reply to author
Forward
0 new messages