washo4evr / Socket.io-v1.x-Library

Socket.io Library for Arduino
108 stars 58 forks source link

problems Upgradeing websocket : openshilft #27

Open strimbob opened 8 years ago

strimbob commented 8 years ago

Hi there

thanks for the Library! and I got it working on localhost. However when i try to connect to it on openshift it give me a HTTP/1.1 400 Bad Request when upgrading the socket it think. The sever gets the initial connection fine but then the arduino give the error. I have put a Serial.print to show that it if does not get pass if (atoi(&databuffer[9]) != 101) {

screen shot 2016-09-07 at 11 40 44 screen shot 2016-09-07 at 11 41 58

any help would be fantastic, as this Library is amazing !!

Best Ben

strimbob commented 8 years ago

I think it might not be this getting the file client.print(F("GET /socket.io/1/websocket/?transport=websocket&b64=true&sid="));

washo4evr commented 8 years ago

Hi, Thanks for using my library. We will figure it out together

1st off, I think you have an issue since your SID is empty can you check on your node server console if you have some kind of error? int sidindex = tmp.indexOf("sid"); int sidendindex = tmp.indexOf("\"", sidindex + 6); int count = sidendindex - sidindex - 6;

for (int i = 0; i < count; i++)
{
    sid[i] = databuffer[i + sidindex + 6];
}
Serial.println(" ");
Serial.print(F("Connected. SID="));

that part needs to output your SID as it is needed for the next step

strimbob commented 8 years ago

hi

great, super excited to get this up and running

this is the output from a io.on('connection', function (socket) { // Incoming connections from clients console.log(socket); on the sever

{ nsp: { name: '/', server: { nsps: [Object], _path: '/socket.io', _serveClient: true, _adapter: [Function: Adapter], origins: ':_', sockets: [Circular], eio: [Object], engine: [Object] }, sockets: [ [Object], [Object], [Circular] ], connected: { EdSAqvrSMEjxhRSzAAAA: [Object], '_LE7wc1w-jwfL1xrAAAB': [Object], cXZjLKpClRBrL25mAAAC: [Circular] }, fns: [], ids: 0, acks: {}, adapter: { nsp: [Circular], rooms: [Object], sids: [Object], encoder: {} }, _events: { connection: [Function] } }, server: { nsps: { '/': [Object] }, _path: '/socket.io', _serveClient: true, _adapter: [Function: Adapter], origins: ':_', sockets: { name: '/', server: [Circular], sockets: [Object], connected: [Object], fns: [], ids: 0, acks: {}, adapter: [Object], _events: [Object] }, eio: { clients: [Object], clientsCount: 3, pingTimeout: 60000, pingInterval: 25000, upgradeTimeout: 10000, maxHttpBufferSize: 100000000, transports: [Object], allowUpgrades: true, allowRequest: [Function], cookie: 'io', ws: [Object], _events: [Object] }, engine: { clients: [Object], clientsCount: 3, pingTimeout: 60000, pingInterval: 25000, upgradeTimeout: 10000, maxHttpBufferSize: 100000000, transports: [Object], allowUpgrades: true, allowRequest: [Function], cookie: 'io', ws: [Object], _events: [Object] } }, adapter: { nsp: { name: '/', server: [Object], sockets: [Object], connected: [Object], fns: [], ids: 0, acks: {}, adapter: [Circular], _events: [Object] }, rooms: { EdSAqvrSMEjxhRSzAAAA: [Object], '_LE7wc1w-jwfL1xrAAAB': [Object], cXZjLKpClRBrL25mAAAC: [Object] }, sids: { EdSAqvrSMEjxhRSzAAAA: [Object], '_LE7wc1w-jwfL1xrAAAB': [Object], cXZjLKpClRBrL25mAAAC: [Object] }, encoder: {} }, id: 'cXZjLKpClRBrL25mAAAC', client: { server: { nsps: [Object], _path: '/socket.io', _serveClient: true, _adapter: [Function: Adapter], origins: ':_', sockets: [Object], eio: [Object], engine: [Object] }, conn: { id: 'cXZjLKpClRBrL25mAAAC', server: [Object], upgraded: false, readyState: 'open', writeBuffer: [Object], packetsFn: [Object], sentCallbackFn: [], request: [Object], checkIntervalTimer: null, upgradeTimeoutTimer: null, pingTimeoutTimer: [Object], transport: [Object], _events: [Object] }, encoder: {}, decoder: { reconstructor: null, _callbacks: [Object] }, id: 'cXZjLKpClRBrL25mAAAC', request: { _readableState: [Object], readable: false, domain: null, _events: {}, _maxListeners: 10, socket: [Object], connection: [Object], httpVersion: '1.1', complete: false, headers: [Object], trailers: {}, _pendings: [], _pendingIndex: 0, url: '/socket.io/1/?transport=polling&b64=true', method: 'GET', statusCode: null, client: [Object], _consuming: true, _dumped: true, httpVersionMajor: 1, httpVersionMinor: 1, upgrade: false, _query: [Object], res: [Object], cleanup: [Function: cleanup], read: [Function] }, onclose: [Function], ondata: [Function], ondecoded: [Function], sockets: [ [Circular] ], nsps: { '/': [Circular] } }, conn: { id: 'cXZjLKpClRBrL25mAAAC', server: { clients: [Object], clientsCount: 3, pingTimeout: 60000, pingInterval: 25000, upgradeTimeout: 10000, maxHttpBufferSize: 100000000, transports: [Object], allowUpgrades: true, allowRequest: [Function], cookie: 'io', ws: [Object], _events: [Object] }, upgraded: false, readyState: 'open', writeBuffer: [ [Object] ], packetsFn: [ undefined ], sentCallbackFn: [], request: { _readableState: [Object], readable: false, domain: null, _events: {}, _maxListeners: 10, socket: [Object], connection: [Object], httpVersion: '1.1', complete: false, headers: [Object], trailers: {}, _pendings: [], _pendingIndex: 0, url: '/socket.io/1/?transport=polling&b64=true', method: 'GET', statusCode: null, client: [Object], _consuming: true, _dumped: true, httpVersionMajor: 1, httpVersionMinor: 1, upgrade: false, _query: [Object], res: [Object], cleanup: [Function: cleanup], read: [Function] }, checkIntervalTimer: null, upgradeTimeoutTimer: null, pingTimeoutTimer: { _idleTimeout: 85000, _idlePrev: [Object], _idleNext: [Object], _idleStart: 1473415565664, _monotonicStartTime: 14186676456, _onTimeout: [Function], _repeat: false }, transport: { readyState: 'opening', maxHttpBufferSize: 100000000, supportsBinary: false, _events: [Object], sid: 'cXZjLKpClRBrL25mAAAC', req: null, res: null, writable: false }, _events: { close: [Object], data: [Function] } }, rooms: [], acks: {}, connected: true, disconnected: false, handshake: { headers: { host: 'wsexample-nodel.rhcloud.com', origin: 'Arduino', 'x-forwarded-for': '77.168.5.100', 'x-client-ip': '77.168.5.100', 'x-forwarded-proto': 'http', 'x-forwarded-host': 'wsexample-nodel.rhcloud.com', 'x-forwarded-port': 'undefined', connection: 'keep-alive' }, time: 'Fri Sep 09 2016 06:06:05 GMT-0400 (EDT)', address: { address: '127.3.206.1', family: 'IPv4', port: 8080 }, xdomain: true, secure: false, issued: 1473415565665, url: '/socket.io/1/?transport=polling&b64=true', query: { transport: 'polling', b64: 'true' } } }

looks like it is getting a sid sids: { EdSAqvrSMEjxhRSzAAAA: [Object], '_LE7wc1w-jwfL1xrAAAB': [Object], cXZjLKpClRBrL25mAAAC: [Object] },

not getting any errors from the sever that i can see thanks for the help!!

Best Ben

washo4evr commented 7 years ago

Hi, how many devices are connecting at the same time? you should only get 1 SID I havent had time to try on openshift to see though