Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WS on HTTP vs WSS on HTTPS

I've read that WS only works on HTTP, and that WSS works on both HTTP and HTTPS. Are WSS (Secure Web Socket) connections just as secure on an HTTP server as they are on an HTTPS server? Is a Web Socket Secure (WSS) connection still encrypted through TLS/SSL if the website/server is not?

like image 403
Isaac Avatar asked Nov 06 '14 23:11

Isaac


People also ask

What is difference between WSS and WS?

The wss protocol establishes a WebSocket over an encrypted TLS connection, while the ws protocol uses an unencrypted connection. At this point, the network connection remains open and can be used to send WebSocket messages in either direction.

Does WebSocket use HTTP or HTTPS?

Almost all the real-time applications like (trading, monitoring, notification) services use WebSocket to receive the data on a single communication channel. Simple RESTful application uses HTTP protocol which is stateless. All the frequently updated applications used WebSocket because it is faster than HTTP Connection.

Should I use WebSockets instead of HTTP?

WebSockets allow for a higher amount of efficiency compared to REST because they do not require the HTTP request/response overhead for each message sent and received. When a client wants ongoing updates about the state of the resource, WebSockets are generally a good fit.

Can HTTP connect to WSS?

"ws protocol" and "wss protocol" are strange words. "WebSocket protocol" is the right word. WebSocket protocol can be used over both plain HTTP connections ( http ) and secure HTTP connections ( https ). Note that communication between a WebSocket client and a WebSocket server starts as a normal HTTP protocol.


1 Answers

"wss works on both http and https" ??? This is a strange phrase.

wss is secure only because it means "WebSocket protocol over https". WebSocket protocol itself is not secure. There is no Secure WebSocket protocol, but there are just "WebSocket protocol over http" and "WebSocket protocol over https". See also this answer.

As the author of nv-websocket-client (WebSocket client library for Java), I also doubt the phrase "if the HTML/JavaScript that opens the secure WebSocket connection comes over non-secure HTTP, the WebSocket connection is still secure" in the answer by oberstet.

Read RFC 6455 (The WebSocket Protocol) to reach the right answer. To become a true engineer, don't avoid reading RFCs. Only searching technical blogs and StackOverflow for answers will never bring you to the right place.

like image 140
Takahiko Kawasaki Avatar answered Oct 22 '22 23:10

Takahiko Kawasaki