Hi guys!
I am need connect to socket.io server writen on node.js and using socket.io. I test this server not only Corona and server working good, it print to console that connection was successfull. But in Corona I can’t connect to the same socket server. I got error
Noobhub connection error: host or service not provided, or not known
Link to this library: NoobHub
I use code:
crypto = require("crypto") require("noobhub") latencies = {} hub = noobhub.new({ server = "http://194.242.102.33"; port = 9999; }); hub:subscribe({ channel = "ping-channel"; callback = function(message) print("message received = "..json.encode(message)); if(message.action == "ping") then ---------------------------------- print ("pong sent"); hub:publish({ message = { action = "pong", id = message.id, original\_timestamp = message.timestamp, timestamp = system.getTimer() } }); end;---------------------------------------------------------------- if (message.action == "pong" ) then ---------------------------------- print ("pong id "..message.id.." received on "..system.getTimer().."; summary: latency=" .. (system.getTimer() - message.original\_timestamp) ); table.insert( latencies, ( (system.getTimer() - message.original\_timestamp) ) ); local sum = 0; local count = 0; for i,lat in ipairs(latencies) do sum = sum + lat; count = count+1; end print("---------- "..count..') average = '..(sum/count) ); native.showAlert( "Corona", "---------- "..count..') average = '..(sum/count), { "OK", "Learn More" }) end;---------------------------------------------------------------- end; }); timer.performWithDelay( 5000, function() print("ping sent"); hub:publish({ message = { action = "ping", id = crypto.digest( crypto.md5, system.getTimer() .. math.random() ), timestamp = system.getTimer() } }); end, 0 );
Can Corona SDK connect to socket server and if yes why I can’t do this?