Closed jbmolle closed 6 years ago
If you take off forceWebsockets does it work? Are you able to check server logs?
Yes I can check server logs. I have socket.on("connection") on the server and it doesn't get called. Should I check something else on the server? If I take off forceWebsockets, it doesn't work. I get: 0{"sid":"Btz7E9OP_NKfwL3IAAAA","upgrades":[websockets],"pingInterval":25000,"pingTimeout":60000} and then it upgrades to websocket and get stuck like when I force it. Thanks, JB
Here is the log on the server for Android: Wed, 12 Jul 2017 13:29:42 GMT engine intercepting request for path "/socket.io/" ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT engine handling "GET" http request "/socket.io/?EIO=3&token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjU4YjVhNDFlNDUzYTcxMTEwMGZhN2U4YSIsImV4cCI6MTQ5OTk0MDYxMC40MDd9.0ZgQ5pFb-OtCcPTDgiHT3pp-7aIT5Ih-42ohk3buJ4I&transport=polling" ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT engine handshaking client "4sX3iIJ1WC_26ZHeAAAA" ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT engine:socket sending packet "open" ({"sid":"4sX3iIJ1WC_26ZHeAAAA","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":60000}) ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT engine:polling setting request ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT engine:socket flushing buffer to transport ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT engine:polling writing "97:0{"sid":"4sX3iIJ1WC_26ZHeAAAA","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":60000}" ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT engine:socket executing batch send callback ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT socket.io:server incoming connection with id 4sX3iIJ1WC_26ZHeAAAA ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT socket.io:client connecting to namespace / ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT socket.io:namespace adding socket to nsp / ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT socket.io:socket socket connected - writing packet ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT socket.io:socket joining room 4sX3iIJ1WC_26ZHeAAAA ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT socket.io:socket packet already sent in initial handshake ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT socket.io:socket joined room 4sX3iIJ1WC_26ZHeAAAA ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT engine intercepting request for path "/socket.io/" ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT engine handling "POST" http request "/socket.io/?EIO=3&token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjU4YjVhNDFlNDUzYTcxMTEwMGZhN2U4YSIsImV4cCI6MTQ5OTk0MDYxMC40MDd9.0ZgQ5pFb-OtCcPTDgiHT3pp-7aIT5Ih-42ohk3buJ4I&sid=4sX3iIJ1WC_26ZHeAAAA&transport=polling" ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT engine setting new request for existing client ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT engine:polling received "�40/user" ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT engine:socket packet ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT socket.io-parser decoded 0/user as {"type":0,"nsp":"/user"} ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT socket.io:client connecting to namespace /user ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT socket.io:namespace adding socket to nsp /user ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT mquery findOne users { _id: 58b5a41e453a711100fa7e8a } { fields: {} } ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT socket.io:socket socket connected - writing packet ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT socket.io:socket joining room /user#4sX3iIJ1WC_26ZHeAAAA ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT socket.io:client writing packet {"type":0,"nsp":"/user"} ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT socket.io-parser encoding packet {"type":0,"nsp":"/user"} ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT socket.io-parser encoded {"type":0,"nsp":"/user"} as 0/user, ellistra-backend_1 | Wed, 12 Jul 2017 13:29:42 GMT engine:socket sending packet "message" (0/user,) ellistra-backend_1 | Connection
Connection means that my socket is connected.
And on iOS I get this: ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine intercepting request for path "/socket.io/" ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine handling "GET" http request "/socket.io/?transport=polling&b64=1&token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjU4YjVhNDFlNDUzYTcxMTEwMGZhN2U4YSIsImV4cCI6MTUwMDQ1Mzg4My4zMzR9.k7NHlgkPD5CJESaqjqCC2dF4SMrb6UJe2v75C5iO190" ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine handshaking client "Koo0tc4_d46CgF21AAAA" ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine:socket sending packet "open" ({"sid":"Koo0tc4_d46CgF21AAAA","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":60000}) ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine:polling setting request ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine:socket flushing buffer to transport ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine:polling writing "97:0{"sid":"Koo0tc4_d46CgF21AAAA","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":60000}" ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine:socket executing batch send callback ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT socket.io:server incoming connection with id Koo0tc4_d46CgF21AAAA ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT socket.io:client connecting to namespace / ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT socket.io:namespace adding socket to nsp / ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT socket.io:socket socket connected - writing packet ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT socket.io:socket joining room Koo0tc4_d46CgF21AAAA ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT socket.io:socket packet already sent in initial handshake ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT socket.io:socket joined room Koo0tc4_d46CgF21AAAA ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine intercepting request for path "/socket.io/" ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine handling "GET" http request "/socket.io/?transport=polling&b64=1&token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjU4YjVhNDFlNDUzYTcxMTEwMGZhN2U4YSIsImV4cCI6MTUwMDQ1Mzg4My4zMzR9.k7NHlgkPD5CJESaqjqCC2dF4SMrb6UJe2v75C5iO190&sid=Koo0tc4_d46CgF21AAAA" ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine setting new request for existing client ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine:polling setting request ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine intercepting request for path "/socket.io/" ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine handling "POST" http request "/socket.io/?transport=polling&b64=1&token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjU4YjVhNDFlNDUzYTcxMTEwMGZhN2U4YSIsImV4cCI6MTUwMDQ1Mzg4My4zMzR9.k7NHlgkPD5CJESaqjqCC2dF4SMrb6UJe2v75C5iO190&sid=Koo0tc4_d46CgF21AAAA" ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine setting new request for existing client ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine:polling received "1:2" ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine:socket packet ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine:socket got ping ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine:socket sending packet "pong" (undefined) ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine:socket flushing buffer to transport ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine:polling writing "1:3" ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine intercepting request for path "/socket.io/" ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine handling "GET" http request "/socket.io/?transport=polling&b64=1&token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjU4YjVhNDFlNDUzYTcxMTEwMGZhN2U4YSIsImV4cCI6MTUwMDQ1Mzg4My4zMzR9.k7NHlgkPD5CJESaqjqCC2dF4SMrb6UJe2v75C5iO190&sid=Koo0tc4_d46CgF21AAAA" ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine setting new request for existing client ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine:polling setting request ellistra-backend_1 | Wed, 12 Jul 2017 13:28:24 GMT engine:socket executing batch send callback ellistra-backend_1 | Wed, 12 Jul 2017 13:28:35 GMT engine intercepting request for path "/socket.io/" ellistra-backend_1 | Wed, 12 Jul 2017 13:28:35 GMT engine handling "GET" http request "/socket.io/?transport=polling&b64=1&token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjU4YjVhNDFlNDUzYTcxMTEwMGZhN2U4YSIsImV4cCI6MTUwMDQ1Mzg4My4zMzR9.k7NHlgkPD5CJESaqjqCC2dF4SMrb6UJe2v75C5iO190" ellistra-backend_1 | Wed, 12 Jul 2017 13:28:35 GMT engine handshaking client "ZpfTQvTD3cVYiolHAAAB" ellistra-backend_1 | Wed, 12 Jul 2017 13:28:35 GMT engine:socket sending packet "open" ({"sid":"ZpfTQvTD3cVYiolHAAAB","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":60000}) ellistra-backend_1 | Wed, 12 Jul 2017 13:28:35 GMT engine:polling setting request ellistra-backend_1 | Wed, 12 Jul 2017 13:28:35 GMT engine:socket flushing buffer to transport ellistra-backend_1 | Wed, 12 Jul 2017 13:28:35 GMT engine:polling writing "97:0{"sid":"ZpfTQvTD3cVYiolHAAAB","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":60000}" ellistra-backend_1 | Wed, 12 Jul 2017 13:28:35 GMT engine:socket executing batch send callback ellistra-backend_1 | Wed, 12 Jul 2017 13:28:35 GMT socket.io:server incoming connection with id ZpfTQvTD3cVYiolHAAAB ellistra-backend_1 | Wed, 12 Jul 2017 13:28:35 GMT socket.io:client connecting to namespace / ellistra-backend_1 | Wed, 12 Jul 2017 13:28:35 GMT socket.io:namespace adding socket to nsp / ellistra-backend_1 | Wed, 12 Jul 2017 13:28:35 GMT socket.io:socket socket connected - writing packet ellistra-backend_1 | Wed, 12 Jul 2017 13:28:35 GMT socket.io:socket joining room ZpfTQvTD3cVYiolHAAAB ellistra-backend_1 | Wed, 12 Jul 2017 13:28:35 GMT socket.io:socket packet already sent in initial handshake ellistra-backend_1 | Wed, 12 Jul 2017 13:28:35 GMT socket.io:socket joined room ZpfTQvTD3cVYiolHAAAB ellistra-backend_1 | Wed, 12 Jul 2017 13:28:44 GMT engine intercepting request for path "/socket.io/" ellistra-backend_1 | Wed, 12 Jul 2017 13:28:44 GMT engine handling "GET" http request "/socket.io/?transport=polling&b64=1&token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjU4YjVhNDFlNDUzYTcxMTEwMGZhN2U4YSIsImV4cCI6MTUwMDQ1Mzg4My4zMzR9.k7NHlgkPD5CJESaqjqCC2dF4SMrb6UJe2v75C5iO190" ellistra-backend_1 | Wed, 12 Jul 2017 13:28:44 GMT engine handshaking client "cJMY_CAb3ucdF5HOAAAC" ellistra-backend_1 | Wed, 12 Jul 2017 13:28:44 GMT engine:socket sending packet "open" ({"sid":"cJMY_CAb3ucdF5HOAAAC","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":60000}) ellistra-backend_1 | Wed, 12 Jul 2017 13:28:44 GMT engine:polling setting request ellistra-backend_1 | Wed, 12 Jul 2017 13:28:44 GMT engine:socket flushing buffer to transport
If it can helps
Hi, I've done more digging in the Swift code and I may have found where the problem comes from. In SocketParsable.swift, we join the namespace in the function handleConnect(_ packetNamespace: String) which is called only when we get the event .connect. But I never get this event and so I never join the namespace. In SocketIOClient.swift, when I put this piece of code in open func engineDidOpen(reason: String): if reason == "Connect" { joinNamespace(nsp) } then everything works. I don't know if this hack is good. Nuclearace, let me know what you think. Best, JB
I'll have to look at the namespace logic again. I remember it used to be that it should join the default namespace first, and then move to the other namespace.
We also encountered the same problem, but also solved by the @jbmolle method
this code should be part of the library
We have encountered the same problem and have fixed it the same way. If this code is acceptable it should be released.
This is what the socket.io-protocol states https://github.com/socketio/socket.io-protocol#multiplexing about namespaces.
When the socket.io transport connection is established, a connection attempt to the / namespace is assumed (ie: the server behaves as if the client had sent a CONNECT packet to the / namespace). In order to support multiplexing of multiple sockets under the same transport, additional CONNECT packets can be sent by the client to arbitrary namespace URIs (eg: /another).
That's what this logic should be handling: https://github.com/socketio/socket.io-client-swift/blob/master/Source/SocketIO/Parse/SocketParsable.swift#L42
i have to recview this code for more undertanding but the truth is server on windows is responding to the connect event but server running on linux ubunto 16 is not respondign to the event un least this code is added. i check it in test that logic to see if in that way i get the message form server
We have the same problem, solved by the @jbmolle method
I have solved the same issue by @jbmolle method,thanks
I will look into this more later today.
Namespaces seem to work for me. What versions of the server are y'all using?
Also can you give an example server that doesn't work with this client?
well after a pod update i used 10.0.0 but today i updated to 12.0.0 and in deed in cloud ubuntu server is not working with the namespace without the mentioned solution. in windows locally runing node 6.10 is working perfect. i gave you maore details about the server in minutes
yes send a private message to pass data of the server
You can't write what version the server is running and create a basic example? I suspect it has to do with the way you're making the server where it doesn't create a default namespace.
here is server soket file using loopback and nodejs "use strict";
const assert = require('assert'); const async = require('async'); const _ = require('underscore'); const app = require('../server');
module.exports = function (app, io) { var vendedorSocket = io.of('/vendedor').use(function (socket, next) { var accessToken = socket.handshake.query.accessToken; if (!accessToken) { return next(new Error('There is no access token to make a handshake')); } app.models.AccessToken.findById(accessToken, function (err, accesstoken_inst) { if (err) return next(new Error(err)); if (!accesstoken_inst) return next(new Error('The access token provided is not valid or expired.')) socket.id = accesstoken_inst.id; socket.userId = accesstoken_inst.userId; return next(); }); });
function throwSocketException(socket, message) {
socket.emit('exception', {message: message});
}
vendedorSocket.on('connection', function (socket) {
console.log('Un vendedor se ha conectado');
socket.on('setLocation', function(data){
try{
assert(data.lng, "No longitude provided.");
assert(data.lat, "No latitude provided");
assert(data.idvendedor, "No idvendedor provided");
console.log('Ha cambiado la ubicación de un vendedor');
app.models.mapa.find({where: {vendedorId: data.idvendedor, activa: true }}, function(err, ubicaciones_inst) {
if (err) throw(err);
if(ubicaciones_inst && ubicaciones_inst.length > 0){
ubicaciones_inst.forEach(function (ubicacion) {
ubicacion.activa = false;
ubicacion.save();
});
}
});
var geopoint = {lat: data.lat, lng: data.lng};
app.models.mapa.create({coordenadas: geopoint, activa: true, vendedorId: data.idvendedor, created: Date.now()}, function(err, ubicacion_inst){
if(err) throw(err);
else if(ubicacion_inst){
socket.emit('locationChanged', ubicacion_inst);
}
});
}
catch(ex){
throwSocketException(socket, ex.message);
}
});
});
};
And what version is the server?
@nuclearace
the problem relation with socket.io server commit
Namespace.prototype.use = function(fn){
if (this.server.eio) {
debug('removing initial packet');
delete this.server.eio.initialPacket; // if comment out the code, it works!
}
this.fns.push(fn);
return this;
};
socket.io server version must be greater than / equal 2.0.2
when i call the socket api, web and android is worked except swift
Ah, I think I see what's going on.
If someone wants to try the development branch, I've made some changes. If those work I'll make a new release.
cd2454373a081b54947e3f94b916cdeb8a6c9c33
how to test it
Just use the development branch.
The development branch is working for me.
sorry for the late response, can not test development branch yesterday but now i can confirm is working good in the server it was not working the socket connection. so you may now make a new release.
v12.1.1 has been released.
@nuclearace
I am using the plugin nativescript-socketio which uses: socket.io-client-swift version 9.0.1 and I can not work with namespaces.
Can anybody help me?
@juanitozambada I don't support old versions.
Same Problem, I am using v13.3.0 for swift. here is my code. let manager = SocketManager(socketURL: URL(string: "http://chat.server.com:80/chatroom")!, config: [.forceWebsockets(true)]) let socket = manager.defaultSocket roomId = "testroom"
socket.on("connect") { data, ack in self.socket.emit("authentication", token) self.socket.on("authenticated"){ data, ack in self.socket.emit("join", self.roomId) } }
After authentication successed, join event not working.
2018-10-07 04:53:05.118524+0800 [2534:320512] LOG SocketEngine: Got message: 0{"sid":"gPAyoWxmuZ0fHsbvAAAI","upgrades":[],"pingInterval":25000,"pingTimeout":5000} 2018-10-07 04:53:05.120676+0800 [2534:320357] LOG SocketIOClient{/}: Handling event: ping with data: [] 2018-10-07 04:53:05.120704+0800 [2534:320512] LOG SocketEngine: Got message: 40 got event: ping with items Optional([]) 2018-10-07 04:53:05.121112+0800 [2534:320512] LOG SocketEngine: Writing ws: has data: false 2018-10-07 04:53:05.121272+0800 2534:320512] LOG SocketEngineWebSocket: Sending ws: as type: 2 2018-10-07 04:53:05.121280+0800 [2534:320357] LOG SocketManager: Engine opened Connect 2018-10-07 04:53:05.121647+0800 [2534:320357] LOG SocketIOClient{/}: Socket connected 2018-10-07 04:53:05.121851+0800 [2534:320357] LOG SocketIOClient{/}: Handling event: statusChange with data: [connected] got event: statusChange with items Optional([connected]) 2018-10-07 04:53:05.122398+0800 [2534:320357] LOG SocketIOClient{/}: Handling event: connect with data: ["/"] got event: connect with items Optional(["/"]) socket connected 2018-10-07 04:53:05.124503+0800 [2534:320357] LOG SocketIOClient{/}: Emitting: 2["authentication",{"access_token":"yVzHVY3w3xK1xks8vQPkLpkO6wbkexvGc4vx1i1no4u7g8yzli4rDdeP8A9VGVBRJtKAllb6TYbiXFOUIHz6wZowjyObWj9PM"} 2018-10-07 04:53:05.126258+0800 [2534:320357] LOG SocketIOClient{/}: Adding handler for event: authenticated nsp : / 2018-10-07 04:53:05.126851+0800 [2534:320357] LOG SocketParser: Parsing 0 2018-10-07 04:53:05.128025+0800 [2534:320357] LOG SocketParser: Decoded packet as: SocketPacket {type: 0; data: []; id: -1; placeholders: 0; nsp: /} 2018-10-07 04:53:05.130454+0800 [2534:320512] LOG SocketEngineWebSocket: Sending ws: 2["authentication",{"access_token":"yVzHVY3w3xK1xks8vQPkLpkO6wbkexvGc4vx1i1no4u7g8yzli4rDdeP8A9VGVBRJtKAllb6TYbiXFOUIHz6wZowjyObWj9PM"} 2018-10-07 04:53:05.408410+0800 [2534:320530] LOG SocketEngine: Got message: 3 2018-10-07 04:53:05.408946+0800 [2534:320357] LOG SocketIOClient{/}: Handling event: pong with data: [] got event: pong with items Optional([]) 2018-10-07 04:53:06.036717+0800 [2534:320512] LOG SocketEngine: Got message: 42["authenticated",true] 2018-10-07 04:53:06.037383+0800 [2534:320357] LOG SocketParser: Parsing 2["authenticated",true] 2018-10-07 04:53:06.039344+0800 [2534:320357] LOG SocketParser: Decoded packet as: SocketPacket {type: 2; data: [authenticated, 1]; id: -1; placeholders: -1; nsp: /} 2018-10-07 04:53:06.040202+0800 [2534:320357] LOG SocketIOClient{/}: Handling event: authenticated with data: [1] got event: authenticated with items Optional([1]) receive authenticated event 2018-10-07 04:53:06.041081+0800 [2534:320357] LOG SocketIOClient{/}: Emitting: 2["join","testroom"], Ack: false 2018-10-07 04:53:06.041788+0800 [2534:320512] LOG SocketEngine: Writing ws: 2["join","testroom"] has data: false 2018-10-07 04:53:06.041966+0800 [2534:320512] LOG SocketEngineWebSocket: Sending ws: 2["join","testroom"] as type: 4 2018-10-07 04:53:31.810296+0800 [2534:320357] LOG SocketIOClient{/}: Handling event: ping with data: [] got event: ping with items Optional([]) 2018-10-07 04:53:31.810951+0800 [2534:320545] LOG SocketEngine: Writing ws: has data: false 2018-10-07 04:53:31.811117+0800 [2534:320545] LOG SocketEngineWebSocket: Sending ws: as type: 2 2018-10-07 04:53:32.112808+0800 [2534:320545] LOG SocketEngine: Got message: 3 2018-10-07 04:53:32.113341+0800 [2534:320357] LOG SocketIOClient{/}: Handling event: pong with data: []
hope good news. :)
I followed the sample on socket.io homepage and it didn't work. I have found an error due to the version of socket.io If someone is using on the client side.
You can fix it by changing the socket.io version
https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js
I simply replaced and it worked
<script src = "https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js"> </script>
<script src = "https://code.jquery.com/jquery-1.11.1.js"> </script>
<script>
var socket = io ('localhost: 3000/my-namespace');
socket.on('hello', function (data) {
document.body.innerHTML = '';
document.write (data)
})
</script>
Hi, I've a problem to make my iOS app work with SocketIO namespaces. I have a NodeJS server with SocketIO 2.0.3 and a namespace "/user". On Android everything works good but on iOS it doesn't connect. I'm using the socket.io-client-swift version 10.2.0 I put the log on and here what I get: 2017-07-12 11:02:50.716 Ellistra[5373:65271] LOG SocketIOClient: Handling event: statusChange with data: [SocketIO.SocketIOClientStatus] 2017-07-12 11:02:50.716 Ellistra[5373:65271] LOG SocketIOClient: Adding engine 2017-07-12 11:02:50.718 Ellistra[5373:65358] LOG SocketEngine: Starting engine. Server: http://192.168.2.114 2017-07-12 11:02:50.718 Ellistra[5373:65358] LOG SocketEngine: Handshaking 2017-07-12 11:02:50.952 Ellistra[5373:65360] LOG SocketEngine: Got message: 0{"sid":"Btz7E9OP_NKfwL3IAAAA","upgrades":[],"pingInterval":25000,"pingTimeout":60000} 2017-07-12 11:02:50.953 Ellistra[5373:65360] LOG SocketEngineClient: Connect 2017-07-12 11:02:50.953 Ellistra[5373:65360] LOG SocketEngine: Writing ws: has data: false 2017-07-12 11:02:50.954 Ellistra[5373:65360] LOG SocketEngine: Sending ws: as type: 2 2017-07-12 11:02:50.977 Ellistra[5373:65360] LOG SocketEngine: Got message: 3 2017-07-12 11:03:15.954 Ellistra[5373:65354] LOG SocketEngine: Writing ws: has data: false 2017-07-12 11:03:15.954 Ellistra[5373:65354] LOG SocketEngine: Sending ws: as type: 2 2017-07-12 11:03:15.992 Ellistra[5373:65354] LOG SocketEngine: Got message: 3 2017-07-12 11:03:40.955 Ellistra[5373:65894] LOG SocketEngine: Writing ws: has data: false 2017-07-12 11:03:40.956 Ellistra[5373:65894] LOG SocketEngine: Sending ws: as type: 2 2017-07-12 11:03:45.218 Ellistra[5373:65894] LOG SocketEngine: Got message: 3
I get that indefinitely. Here is how I create my socket: let params: [String: String] = ["token": EllistraSettings.sharedInstance.accessToken!] let config: SocketIOClientConfiguration = [.log(true), .forceWebsockets(true), .connectParams(params), .secure(false), .nsp("/user")] socket = SocketIOClient(socketURL: URL(string: "http://192.168.2.114")!, config: config) // Different SocketIO events, onConnect, onDisconnect, onMessageReceived... socket?.on(...) socket?.connect()
But I never get .connect SocketIO event. Thanks for your help, JB