ngrok icon indicating copy to clipboard operation
ngrok copied to clipboard

How to connect to websocket ws

Open hasanAjsf opened this issue 5 years ago • 3 comments

In my Android app, I'm connecting to websocket as:

val uri = URI("ws://a501045e.ngrok.io:8080/ws")

How can I run ngrok to get the ws:// subdomain instead of the http:// one.

I tried changing the code in Android to be:

val uri = URI("tcp://0.tcp.ngrok.io:18972/ws")

And run ngrok as:

ngrok tcp 8080

to get the connection as in the screenshot below.

But could not get the ws signal at my computer:

    var socket = new WebSocket("ws://127.0.0.1:8080/ws");
//    var socket = new WebSocket("ws://localhost:8080/ws");

None of the above worked, knowing that both worked perfectly with Android emulator, once I defined the connection call as:

val uri = URI("tcp://10.0.2.2:8080/ws")

ngrok

hasanAjsf avatar Aug 31 '19 15:08 hasanAjsf

Don't give val uri = URI("tcp://0.tcp.ngrok.io:18972/ws")

instead try val uri = URI("ws://0.tcp.ngrok.io:18972/ws")

because its still web socket connection.

mihir09 avatar Jan 30 '23 00:01 mihir09

mihir09

Hello, do you have a solution on HTTPS websites? as ws doesn't work no more (Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.)

I understood that the socket must be available over WSS, I tried to changed to wss:// but it failed

VerifyBot avatar Oct 13 '23 19:10 VerifyBot

Same problem here, My browser is complaining about the security handshake not being the correct length.

exposing a ws:// over tcp with ngrok, accessing it over wss;// in the client is not working

kaosbeat avatar Feb 16 '24 12:02 kaosbeat

Thank you for opening this issue! As of April 2016, the ngrok service has permanently moved to https://ngrok.com/. To join the community and file bug reports or feature enhancements for the ngrok agent, please go to https://github.com/ngrok/ngrok.

This repository is no longer actively maintained and will be archived soon to reduce confusion with the latest ngrok versions. We thank you for the continued support of ngrok and look forward to seeing you over at ngrok.com and the ngrok Community Repo.

russorat avatar May 09 '24 19:05 russorat