Giter VIP home page Giter VIP logo

Comments (9)

mbonneau avatar mbonneau commented on July 18, 2024 1

Having a reserved bit means that the server is not following the protocol correctly. During handshake, the client and the server must negotiate any extensions before they can use them. My guess is that whatever server software you are connecting to is using a sub-protocol without agreeing with the client (perhaps it is assuming that you are using compression).

Without a capture or more information about the server, it is not possible for me to figure out what is going on. For more information on how to capture network traffic, dig into tcpdump.

Or try sudo tcpdump -s 0 -w somefile.cap port <WebSocketPort> to capture everything on the websocket port to a file. (Some adjustments to that command may be required depending on your system).

This file will contain the server addresses and related information that you may not want to post. Unfortunately, I do not have a telegram, but I do have email.

from rfc6455.

mbonneau avatar mbonneau commented on July 18, 2024 1

permessage-deflate is implemented in the permessage-deflate branch that has not been merged yet.

from rfc6455.

mbonneau avatar mbonneau commented on July 18, 2024

@NabiKAZ What browser are you using on what OS? Can you post code examples to reproduce this?

from rfc6455.

NabiKAZ avatar NabiKAZ commented on July 18, 2024

@mbonneau Thanks for response.

As I said, The code is default example:

<?php

require __DIR__ . '/vendor/autoload.php';

$loop = React\EventLoop\Factory::create();

$connector = new Ratchet\Client\Connector($loop);

$connector('ws://................................', [], [.............................])

->then(function(Ratchet\Client\WebSocket $conn) {
	$conn->on('message', function(\Ratchet\RFC6455\Messaging\MessageInterface $msg) use ($conn) {
		echo "Received: {$msg}\n";
		//$conn->close();
	});

	$conn->on('close', function($code = null, $reason = null) {
		echo "Connection closed ({$code} - {$reason})\n";
	});

	$conn->send('hello');
}, function(\Exception $e) use ($loop) {
	echo "Could not connect: {$e->getMessage()}\n";
	$loop->stop();
});

$loop->run();
Windows 10 64-bit
PHP 7.0.4 (cli) (built: Mar  2 2016 14:42:25) ( ZTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

"hello" message was sent, but didn't received any replay data, and so closed connection!

But this code don't have any problem in send and received data:

<html>
<head>
<title>WebSocket</title>

<style>
 html,body{font:normal 0.9em arial,helvetica;}
 #log {width:1200px; height:500px; border:1px solid #7F9DB9; overflow:auto;}
 #msg {width:330px;}
</style>

<script>
var socket;

function connect(){
  var host = $("server").value;
  try{
    socket = new WebSocket(host);
    log('WebSocket - status '+socket.readyState);

    socket.onopen    = function(msg){ log("Welcome - status "+this.readyState); };
    socket.onmessage = function(msg){ log("Received: "+msg.data); };
    socket.onclose   = function(msg){ log("Disconnected - status "+this.readyState); };
  }
  catch(ex){ log(ex); }
  $("msg").focus();
}

function send(){
  var txt,msg;
  txt = $("msg");
  msg = txt.value;
  if(!msg){ alert("Message can not be empty"); return; }
  txt.value="";
  txt.focus();
  try{ socket.send(msg); log('Sent: '+msg); } catch(ex){ log(ex); }
}
function quit(){
  log("Goodbye!");
  socket.close();
  socket=null;
}

// Utilities
function $(id){ return document.getElementById(id); }
function log(msg){ $("log").innerHTML+="\n"+msg; }
function onkey(event){ if(event.keyCode==13){ send(); } }
</script>

</head>
<body>
<h3>WebSocket v2.00</h3>
 <input id="server" size="50"><button onclick="connect()">Connect</button>
 <div id="log"></div>
 <input id="msg" type="textbox" onkeypress="onkey(event)"/>
 <button onclick="send()">Send</button>
 <button onclick="quit()">Quit</button>
</body>
</html>

from rfc6455.

mbonneau avatar mbonneau commented on July 18, 2024

What browser are you connecting with? Any other info (request and response headers on the websocket connection and a packet capture if possible) would be helpful.

from rfc6455.

NabiKAZ avatar NabiKAZ commented on July 18, 2024

I use Version 69.0.3497.100 (Official Build) (64-bit) But as I said this problem is on CLI PHP and don't dependency with browser.
I don't know how to do: request and response headers on the websocket connection and a packet capture if possible.

I think the server is a special kind!
I can not leave my address here. If you have a telegram to send to you?

from rfc6455.

NabiKAZ avatar NabiKAZ commented on July 18, 2024

Ok, Please send me your email.

from rfc6455.

NabiKAZ avatar NabiKAZ commented on July 18, 2024

Oops! You pointed to the right compression issue. The problem was this: 'Sec-WebSocket-Extensions' => 'permessage-deflate', and the problem was resolved by remove it.
Thank you very much. 😍

But how can one keep it and solve the problem in principle? I tested with PHP 7.2.4, but there is still a problem with permessage-deflate.

from rfc6455.

cboden avatar cboden commented on July 18, 2024

The permessage-deflate branch has been merged into master and tagged.

from rfc6455.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.