Rolando
Rolando

Reputation: 62596

Can a web browser client connect directly to a remote websocket server?

Assuming I have an apache server with an html page, can I include javascript on that html page that attempts to connect to `ws://remote-server.com:24325' to receive messages from the remote host? Most examples I see online are having html pages with javascript that connect to a localhost websocket server like: ws://localhost:24325

Upvotes: 1

Views: 4437

Answers (1)

jfriend00
jfriend00

Reputation: 707148

Yes, you can use Javascript in your page to connect to a remote server via a webSocket connection. That's what the webSocket functionality built into a browser is for.

The localhost examples you see are probably just examples for local development testing.

Of course, in order to connect to a given host, that host must be running a webSocket server and be accepting incoming connections.

Upvotes: 2

Related Questions