维基百科似乎websockets是安全的:
对于Web浏览器支持,WebSocket协议的安全版本在Firefox 6(名为MozWebSocket),[2] Google Chrome 14 [3]和Internet Explorer 10开发人员预览版中实现....虽然没有已知的漏洞,但它在Firefox 4和5中被禁用...
但W3表示他们不安全:
遵循HTTP过程可能会在Web浏览器上下文中引入严重的安全问题.例如,考虑在一个路径上具有WebSocket服务器的主机和在另一个路径上具有打开的HTTP重定向器的主机.突然之间,任何可以被赋予特定WebSocket URL的脚本都可以被欺骗与Internet上的任何主机进行通信(并且可能与之共享机密),即使脚本检查URL具有正确的主机名.
是http websockets(ws :)安全与否?
是https websockets(wss :)安全与否?
如果不是#2,是否有记录的预防措施?
我目前正在研究Python中的websocket支持,并且对这些产品感到有些困惑.
一方面可以使用Flask + gevent.另一方面,uwsgi有socket支持,最后有一个扩展包括uwsgi和gevent.
实现仅包含其中一个的websockets有什么问题?混合它们我会赢得什么?
改变问题
添加gevent做什么线程uwsgi不会?
我发现这个python脚本应该允许我打开一个WebSocket.但是,[W 1402720 14:44:35 web:1811] 403 GET / (192.168.0.102) 11.02 ms当我尝试打开实际的WebSocket(使用Old WebSocket Terminal Chrome插件)时,我在Linux终端中收到警告.永远不会在终端窗口中打印消息"连接已打开","连接已关闭"和"已接收消息".
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
import tornado.websocket
class MyHandler(tornado.websocket.WebSocketHandler):
def open(self):
print "connection opened"
self.write_message("connection opened")
def on_close(self):
print "connection closed"
def on_message(self,message):
print "Message received: {}".format(message)
self.write_message("message received")
if __name__ == "__main__":
tornado.options.parse_command_line()
app = tornado.web.Application(handlers=[(r"/",MyHandler)])
server = tornado.httpserver.HTTPServer(app)
server.listen(8888)
tornado.ioloop.IOLoop.instance().start()
Run Code Online (Sandbox Code Playgroud) 我已经读过WS只适用于HTTP,而且WSS适用于HTTP和HTTPS.WSS(安全Web套接字)连接在HTTP服务器上是否与在HTTPS服务器上一样安全?如果网站/服务器不是通过TLS/SSL加密的Web Socket安全(WSS)连接?
我终于让socket.io正常工作,但我遇到了一个奇怪的问题.
我不确定这是不是最好的方法,但我使用的是:
io.sockets.clients().length
Run Code Online (Sandbox Code Playgroud)
这将返回连接到我的服务器的客户端数量.问题是在用户连接和断开连接后,数量开始保持高于应有的水平.
例如,如果我连接并询问我的朋友,数字会上升,这是正确的.但是当我们开始断开连接并重新连接时,数量不会减少.
我在vmware ubuntu服务器上运行node.js和sockets.io服务器.
有谁知道为什么这是或有更好的方法来找出有多少人连接到服务器?
有时当我重新启动服务器或网络出现故障时,websocket会关闭,我希望能够始终获得当前的连接状态.
我基本上得到以下错误,我希望能够预测它:
WebSocket is already in CLOSING or CLOSED state.
(anonymous function)
InjectedScript._evaluateOn
InjectedScript._evaluateAndWrap
InjectedScript.evaluate
Run Code Online (Sandbox Code Playgroud) 我有以下情况:
var options = {
protocols_whitelist : [ "websocket", "xhr-streaming", "xdr-streaming", "xhr-polling", "xdr-polling", "iframe-htmlfile", "iframe-eventsource", "iframe-xhr-polling" ],
debug : false
};
var socket = new SockJS("/mmyurl/",undefined,options);
var stompClient = Stomp.over(socket);
stompClient.connect({
company : "XXXXX"
}, function(frame) {
stompClient.subscribe('/topic/mytopic', function(message){
var myitem = JSON.parse(message.body);
});
Run Code Online (Sandbox Code Playgroud)
一切正常,问题是在javascript控制台上充满了这样的调试消息:
<<< MESSAGE
content-type:application/json;charset=UTF-8
subscription:sub-1
message-id:o6g660dt-113
destination:/topic/mytopic
content-length:411
Run Code Online (Sandbox Code Playgroud)
我想禁用这些消息.
我试图改变一些选项,并试图简单地注册:
var socket = new SockJS("/mmyurl/");
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
有没有办法禁用调试消息?
任何帮助表示赞赏
我正在使用包含STOMP/SockJS WebSocket的Spring Boot(1.3.0.BUILD-SNAPSHOT)设置RESTful Web应用程序,我打算从iOS应用程序和Web浏览器中使用它.我想使用JSON Web令牌(JWT)来保护REST请求和WebSocket接口,但我对后者有困难.
该应用程序使用Spring Security进行保护: -
@Configuration
@EnableWebSecurity
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
public WebSecurityConfiguration() {
super(true);
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("steve").password("steve").roles("USER");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.exceptionHandling().and()
.anonymous().and()
.servletApi().and()
.headers().cacheControl().and().and()
// Relax CSRF on the WebSocket due to needing direct access from apps
.csrf().ignoringAntMatchers("/ws/**").and()
.authorizeRequests()
//allow anonymous resource requests
.antMatchers("/", "/index.html").permitAll()
.antMatchers("/resources/**").permitAll()
//allow anonymous POSTs to JWT
.antMatchers(HttpMethod.POST, "/rest/jwt/token").permitAll()
// Allow anonymous …Run Code Online (Sandbox Code Playgroud) 我想以双向流方式开发客户端 - 服务器应用程序.
什么是更合适的技术 - grpc或websocket?
我不理解RFC 6455中"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"的含义.为什么服务器需要这个神奇的字符串?为什么WebSocket协议需要这种机制?