Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6629693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:17:48+00:00 2026-05-25T22:17:48+00:00

I’m trying to implement the new hybi-10 protocol in a python server and for

  • 0

I’m trying to implement the new hybi-10 protocol in a python server and for now I succeeded in the handshake and receiving data from the client (JavaScript) but now I’m having problems with sending the data to the client.

I’m using a bit of a code from websockify (encode_hybi function) to encode the frames according to this protocol. But unfortunately the client doesn’t seem to receive the data, as the on message event never fires.

So the code I have is this:

def encode_hybi(self, buf, opcode = 0x01):

    buf = b64encode(buf)

    b1 = 0x80 | (opcode & 0x0f) 
    payload_len = len(buf)
    if payload_len <= 125:
        header = struct.pack('>BB', b1, payload_len)
    elif payload_len > 125 and payload_len < 65536:
        header = struct.pack('>BBH', b1, 126, payload_len)
    elif payload_len >= 65536:
        header = struct.pack('>BBQ', b1, 127, payload_len)

    print repr(header + buf)

    return header + buf

def send(self, data):
    logging.info("Message Sent: %s" % data)

    if (self.protocol == 'hixie-76'):
        self.client.send("\x00%s\xff" % data)
    elif (self.protocol =='hybi-10'):
        msg = self.encode_hybi(data)
        self.client.send(msg)

I’m sending a simple 'OK' through the socket. So after the encode_hybi function I get:
'\x81\x04T0s=' which is sent to JavaScript. I have no response from it, nor errors.

I tried to send other data, for example 'OKKK'. After the encode_hybi function I get: '\x81\x08T0tLSw=='. Don’t know if it helps, but with this data sent, the JavaScript presents an error:

Unrecognized frame opcode: 13.

This error appears every time the length of the data sent is bigger than 3 characters.

I really can’t understand the problem. Is something wrong in the encoding?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:17:49+00:00Added an answer on May 25, 2026 at 10:17 pm

    You used \n\r\n\r\n at the end of the handshake format, but it should be \r\n\r\n. Currently the \n is part of the key.

    Although I don’t understand how you were still able to open a connection, it looks like removing the first \n solves the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from
I am trying to loop through a bunch of documents I have to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.