ghedipunk / PHP-Websockets

A Websockets server written in PHP.
BSD 3-Clause "New" or "Revised" License
913 stars 375 forks source link

failed: One or more reserved bits are on: reserved1 = 1, reserved2 = 1, reserved3 = 1 #77

Closed zuoweiphp closed 8 years ago

zuoweiphp commented 8 years ago

when I used

protected function send($user, $message) {
    if ($user->handshake) {
      $message = $this->frame($message,$user);
      foreach($this->sockets as $v) {
          $result = @socket_write($v, $message, strlen($message));
      }
    }
    else {
      // User has not yet performed their handshake.  Store for sending later.
      $holdingMessage = array('user' => $user, 'message' => $message);
      $this->heldMessages[] = $holdingMessage;
    }
  }
ghedipunk commented 8 years ago

There's not enough information to go on here to start troubleshooting the problem.

You pasted code that hundreds of others are using without issue, and aren't including how you're calling that code.

Also, I can tell you with absolute certainty that the cause of your issue isn't coming from any one of those lines of code that you posted.

Posting that your WebSockets connection failed because reserved bits are being used, and posting the body of the send() method is like walking up to a veterinarian, saying your pet keeps on puking, then describing how a mouth is supposed to work. Sure, the puke comes out of the mouth, but that's not the cause of the pet's problem, and without bringing the pet around (or at least giving hints about what might be causing the pet's distress, like any changes in diet, access to poison, etc.,) then the veterinarian isn't going to be able to help... and just like our hypothetical veterinarian doesn't know if your pet is a cat, dog, horse, or fish, we don't know what type of server you're writing, whether it's a data feed, a chat server, a game network layer, or whatever.

So, quick bit of homework for you: Figure out what's relevant, and what we can use to start troubleshooting your issue. We do want to help. Helping feeds our egos, and in the world of open source software, that's really the only compensation we can expect. We can't help you if we don't know what to help with, though.

Xaraknid commented 7 years ago

First rsv bit are bug because they are considered string when they should be INT.

Second you should check this function

checkRSVBits($headers,$user) { // override this method if you are using an extension where the RSV bits are used.