Skip to content

receive extra character when on listening #11

Description

@SuperCipher

receive extra character when using .on listening method

client side (python)

python 2.7
OSX

import logging
from socketIO_client import SocketIO, BaseNamespace

logging.getLogger('socketIO-client').setLevel(logging.DEBUG)
logging.basicConfig()

def on_test_response(*args):
    print('on_test_response', args)

def on_connect():
    print('connect')


def on_disconnect():
    print('disconnect')


def on_fps_com_response(*args):
    print('on_fps_com_response', args)


class FpsNamespace(BaseNamespace):

    def on_fps_com_response(self, *args):
        print('on_fps_com_response', args)


socketIO = SocketIO('https://localhost', 8080, verify=False)
FpsNamespace = socketIO.define(FpsNamespace, '/fps-namespace')

data = ''

FpsNamespace.emit('fps_com', 'aaa')
FpsNamespace.on('fps_com', on_fps_com_response)

socketIO.wait(seconds=5)

what receive from the client-end (received the unexpected)

expect to receive
copy
actual recieve
(u'copy',)

server side code

"socket.io": "^1.7.3"
nodeJs 8.6.0
OSX

const fps_nsp = io.of('/fps-namespace');
fps_nsp.on('connection', (socket) => {
  // socket.emit('fps_com', { hello: 'Hey there browser!' });
  socket.on('fps_com', (data) => {
    console.log(data);
    socket.emit('fps_com', 'copy');
  });
  socket.on('disconnect', () => {
    console.log('Socket disconnected');
  });
});

what recieve from the server-end (recieved as expected)
aaa

If I change the code in client side (python) from verify=False to verify='cert.pem'
I got an error

ERROR:urllib3.connection:Certificate did not match expected hostname: localhost. Certificate: {'notBefore': u'Aug 29 09:08:30 2017 GMT', 'serialNumber': u'9A6416AB3B2A6919', 'notAfter': 'Aug 29 09:08:30 2018 GMT', 'version': 3L, 'subject': ((('countryName', u'TH'),), (('stateOrProvinceName', u'xxx'),), (('localityName', u'xxx'),), (('organizationName', u'Fps moonshot Ltd'),), (('organizationalUnitName', u'Fps developer'),), (('commonName', u'xxx'),), (('emailAddress', u'email@hotmail.com'),)), 'issuer': ((('countryName', u'TH'),), (('stateOrProvinceName', u'xxx'),), (('localityName', u'xxx'),), (('organizationName', u'Fps moonshot Ltd'),), (('organizationalUnitName', u'Fps developer'),), (('commonName', u'xxx'),), (('emailAddress', u'email@hotmail.com'),))}
WARNING:socketIO-client-2:localhost:8080/socket.io [waiting for connection] HTTPSConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /socket.io/?EIO=3&transport=polling&t=1504204491104-0 (Caused by SSLError(CertificateError("hostname 'localhost' doesn't match u'xxx'",),))

Ps. Sorry for being a newbie and Thank you for answering
@feus4177

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions