Building42 / Telegraph

Secure Web Server for iOS, tvOS and macOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I can't send msg by wss connect

wyxy2005 opened this issue · comments

commented

I use demo test,but demo can't send msg by wss connect.test address(wss://127.0.0.1:8585)

So long as send a msg ,the server quick close and xcode show msg:
Error Domain=GCDAsyncSocketErrorDomain Code=7 "Socket closed by remote peer" UserInfo={NSLocalizedDescription=Socket closed by remote peer}

I use js is ok. code demo:

<script>
var ws = new WebSocket("wss://127.0.0.1:8585");
var close = false;

// 心跳 		10秒一次
ref = setInterval(function() {
	ws.send('{"type":"ping"}');
}, 10000);
ws.onopen = function(){
	ws.send('{"type":"www"}');
};
ws.onmessage = function(e) {
	var json = JSON.parse(e.data);
	var type = json.type;
	var data = json.data;
	console.log(e.data);
};
</script>
commented

I'm use php provide wss service . the server console show err log:"frame not masked so close the connection" and find the workerman soucecode:
1565755982425

commented

... Only set config:
client?.config.maskMessages = true

commented

So it's not a bug!

@wyxy2005 Great, I see you already found the solution!

Telegraph by default only enables WebSocket masks if the messages are passed over an unsecure connection (HTTP). For secure connections the mask is default false.

I would have to check the spec if this is correct.