WSS适用于http? [英] WSS works on http?

查看:854
本文介绍了WSS适用于http?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有可能在http上使用wss协议吗?我在一个与http合作的论坛上阅读过,但wss只适用于https?
这是真的吗?

It is possible having a wss protocol over http ? i've read on a forum that ws work with http, but wss works only with https ? Is that true ?

因为我试图在我的whost on localhost上测试它,但是没有工作

Cause i'm trying to test it on my wamp on localhost, but not working

推荐答案

ws 告诉WebSocket客户端库使用 http 连接到WebSocket服务器。同样, wss 告诉WebSocket客户端库使用 https 连接到WebSocket服务器。只是。 ws protocol和wss protocol是奇怪的词。 WebSocket协议是正确的词。 WebSocket协议可用于普通HTTP连接( http )和安全HTTP连接( https )。

ws tells a WebSocket client library to use http to connect to a WebSocket server. Likewise, wss tells a WebSocket client library to use https to connect to a WebSocket server. Just that. "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).

请注意,WebSocket客户端和WebSocket服务器之间的通信是作为普通的HTTP协议启动的。要启动WebSocket通信,WebSocket客户端会将如下所示的请求发送到WebSocket服务器(这是RFC 6455的摘录, 1.2。协议概述)。

Note that communication between a WebSocket client and a WebSocket server starts as a normal HTTP protocol. To start WebSocket communication, a WebSocket client sends a request like below to a WebSocket server (This is an excerpt from RFC 6455, 1.2. Protocol Overview).

GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Origin: http://example.com
Sec-WebSocket-Protocol: chat, superchat
Sec-WebSocket-Version: 13

As你可以看到,这是一个普通的HTTP GET 请求。 WebSocket服务器可以在不安全的端口上等待此类请求( http ,默认为80)或安全端口( https ,443是默认值)。这取决于WebSocket服务器。

As you can see, this is a normal HTTP GET request. A WebSocket server can wait for this kind of requests on an unsecured port (http, 80 is the default) or on a secured port (https, 443 is the default). It's up to WebSocket servers.

如果您使用的WebSocket服务器正在等待不安全端口上的请求,请传递 ws 到您正在使用的WebSocket客户端库。否则,如果WebSocket服务器正在等待安全端口上的请求,请将 wss 传递给WebSocket客户端库。

If a WebSocket server you are using is waiting for requests on an unsecured port, pass ws to a WebSocket client library you are using. Otherwise, if the WebSocket server is waiting for requests on a secured port, pass wss to the WebSocket client library.

WebSocket客户端库的某些实现不仅接受 ws wss ,还接受 http https 只是为了方便开发人员。

Some implementations of WebSocket client libraries accept not only ws and wss but also http and https just for developers' convenience.

WSS on http是一个奇怪的词。另一方面,httpS上的WebSocket协议和https上的WebSocket协议是有道理的。

"WSS on http" is a strange word. On the other hand, "WebSocket protocol on http" and "WebSocket protocol on https" make sense.

这篇关于WSS适用于http?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆