Error while connecting back to socket
2018-09-10 18:09:02.854385+0530 SmartKey[60090:8213349] LOG SocketEnginePolling: Got polling response
2018-09-10 18:09:02.854600+0530 SmartKey[60090:8213349] LOG SocketEnginePolling: Got poll message: 1:3
2018-09-10 18:09:02.854823+0530 SmartKey[60090:8213349] LOG SocketEngine: Got message: 3
2018-09-10 18:09:02.855061+0530 SmartKey[60090:8213025] LOG SocketIOClient{/}: Handling event: pong with data: []
2018-09-10 18:09:02.855793+0530 SmartKey[60090:8213349] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=YA92qtD5hNZRp8nmAALu
2018-09-10 18:09:06.091503+0530 SmartKey[60090:8213025] LOG SocketIOClient{/}: Closing socket
2018-09-10 18:09:06.091590+0530 SmartKey[60090:8213025] LOG SocketIOClient{/}: Disconnected: Disconnect
2018-09-10 18:09:06.091844+0530 SmartKey[60090:8213025] LOG SocketIOClient{/}: Handling event: statusChange with data: [disconnected]
2018-09-10 18:09:06.091934+0530 SmartKey[60090:8213025] LOG SocketIOClient{/}: Handling event: disconnect with data: ["Disconnect"]
2018-09-10 18:09:08.604440+0530 SmartKey[60090:8213025] [Snapshotting] Snapshotting a view (0x104863800, UIKeyboardImpl) that is not in a visible window requires afterScreenUpdates:YES.
2018-09-10 18:09:19.526034+0530 SmartKey[60090:8213025] LOG SocketIOClient{/}: Handling event: statusChange with data: [connecting]
2018-09-10 18:09:19.526525+0530 SmartKey[60090:8213025] LOG SocketIOClient{/}: Adding handler for event: connect
2018-09-10 18:09:19.528517+0530 SmartKey[60090:8213994] LOG SocketEngine: Writing poll: 0/ has data: false
2018-09-10 18:09:19.528644+0530 SmartKey[60090:8213994] LOG SocketEnginePolling: Sending poll: 0/ as type: 4
2018-09-10 18:09:19.529847+0530 SmartKey[60090:8213994] LOG SocketEnginePolling: Created POST string: 3:40/
2018-09-10 18:09:19.530406+0530 SmartKey[60090:8213994] LOG SocketEnginePolling: POSTing
2018-09-10 18:09:19.530565+0530 SmartKey[60090:8213994] LOG SocketEnginePolling: Doing polling POST http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=YA92qtD5hNZRp8nmAALu
*** Server Request Initiated ***
request sent to api is POST http://103.16.142.162/SmartKey/api/mac/Alarms?MobileNo=9964280738
Request POST http://103.16.142.162/SmartKey/api/mac/Alarms?MobileNo=9964280738
2018-09-10 18:09:19.616097+0530 SmartKey[60090:8213104] TIC Read Status [3:0x1c4173b00]: 1:57
2018-09-10 18:09:19.747540+0530 SmartKey[60090:8213104] LOG SocketEnginePolling: Got polling response
2018-09-10 18:09:19.747852+0530 SmartKey[60090:8213104] LOG SocketEnginePolling: Got poll message: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>500 - Internal server error.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
2018-09-10 18:09:19.749805+0530 SmartKey[60090:8213104] LOG SocketEngine: Got message: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>500 - Internal server error.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
<div class="
2018-09-10 18:09:19.752507+0530 SmartKey[60090:8213025] ERROR SocketManager: Got unknown error from server <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>500 - Internal server error.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="cont
2018-09-10 18:09:19.753029+0530 SmartKey[60090:8213104] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=YA92qtD5hNZRp8nmAALu
2018-09-10 18:09:19.760400+0530 SmartKey[60090:8213025] LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"/>\r\n<title>500 - Internal server error.</title>\r\n<style type=\"text/css\">\r\n<!--\r\nbody{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}\r\nfieldset{padding:0 15px 10px 15px;} \r\nh1{font-size:2.4em;margin:0;color:#FFF;}\r\nh2{font-size:1.7em;margin:0;color:#CC0000;} \r\nh3{font-size:1.2em;margin:10px 0 0 0;color:#000000;} \r\n#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:\"trebuchet MS\", Verdana, sans-serif;color:#FFF;\r\nbackground-color:#555555;}\r\n#content{margin:0 0 0 2%;position:relative;}\r\n.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}\r\n-->\r\n<
2018-09-10 18:09:19.818252+0530 SmartKey[60090:8213693] LOG SocketEnginePolling: Got polling response
2018-09-10 18:09:19.818344+0530 SmartKey[60090:8213693] LOG SocketEnginePolling: Got poll message: Bad Request
2018-09-10 18:09:19.818440+0530 SmartKey[60090:8213693] LOG SocketEngine: Got message: Bad Request
2018-09-10 18:09:19.818560+0530 SmartKey[60090:8213025] ERROR SocketManager: Got unknown error from server Bad Request
2018-09-10 18:09:19.818636+0530 SmartKey[60090:8213025] LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server Bad Request"]
2018-09-10 18:09:19.818864+0530 SmartKey[60090:8213693] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=YA92qtD5hNZRp8nmAALu
2018-09-10 18:09:19.875021+0530 SmartKey[60090:8213104] LOG SocketEnginePolling: Got polling response
2018-09-10 18:09:19.875138+0530 SmartKey[60090:8213104] LOG SocketEnginePolling: Got poll message: Bad Request
2018-09-10 18:09:19.875278+0530 SmartKey[60090:8213104] LOG SocketEngine: Got message: Bad Request
2018-09-10 18:09:19.875502+0530 SmartKey[60090:8213025] ERROR SocketManager: Got unknown error from server Bad Request
2018-09-10 18:09:19.875596+0530 SmartKey[60090:8213025] LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server Bad Request"]
2018-09-10 18:09:19.876007+0530 SmartKey[60090:8213104] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=YA92qtD5hNZRp8nmAALu
2018-09-10 18:09:19.932304+0530 SmartKey[60090:8213902] LOG SocketEnginePolling: Got polling response
2018-09-10 18:09:19.932478+0530 SmartKey[60090:8213902] LOG SocketEnginePolling: Got poll message: Bad Request
2018-09-10 18:09:19.932769+0530 SmartKey[60090:8213902] LOG SocketEngine: Got message: Bad Request
2018-09-10 18:09:19.933205+0530 SmartKey[60090:8213025] ERROR SocketManager: Got unknown error from server Bad Request
2018-09-10 18:09:19.933374+0530 SmartKey[60090:8213025] LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server Bad Request"]
2018-09-10 18:09:19.933759+0530 SmartKey[60090:8213902] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=YA92qtD5hNZRp8nmAALu
2018-09-10 18:09:19.992261+0530 SmartKey[60090:8213902] LOG SocketEnginePolling: Got polling response
2018-09-10 18:09:19.992572+0530 SmartKey[60090:8213902] LOG SocketEnginePolling: Got poll message: Bad Request
2018-09-10 18:09:19.992806+0530 SmartKey[60090:8213902] LOG SocketEngine: Got message: Bad Request
2018-09-10 18:09:19.993420+0530 SmartKey[60090:8213025] ERROR SocketManager: Got unknown error from server Bad Request
2018-09-10 18:09:19.993684+0530 SmartKey[60090:8213025] LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server Bad Request"]
2018-09-10 18:09:19.994291+0530 SmartKey[60090:8213902] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=YA92qtD5hNZRp8nmAALu
2018-09-10 18:09:20.064020+0530 SmartKey[60090:8213902] LOG SocketEnginePolling: Got polling response
2018-09-10 18:09:20.064181+0530 SmartKey[60090:8213902] LOG SocketEnginePolling: Got poll message: Bad Request
2018-09-10 18:09:20.064477+0530 SmartKey[60090:8213902] LOG SocketEngine: Got message: Bad Request
2018-09-10 18:09:20.065261+0530 SmartKey[60090:8213025] ERROR SocketManager: Got unknown error from server Bad Request
2018-09-10 18:09:20.065311+0530 SmartKey[60090:8213902] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=YA92qtD5hNZRp8nmAALu
2018-09-10 18:09:20.065451+0530 SmartKey[60090:8213025] LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server Bad Request"]
2018-09-10 18:09:20.123140+0530 SmartKey[60090:8213719] LOG SocketEnginePolling: Got polling response
2018-09-10 18:09:20.123341+0530 SmartKey[60090:8213719] LOG SocketEnginePolling: Got poll message: Bad Request
2018-09-10 18:09:20.123745+0530 SmartKey[60090:8213719] LOG SocketEngine: Got message: Bad Request
2018-09-10 18:09:20.124075+0530 SmartKey[60090:8213025] ERROR SocketManager: Got unknown error from server Bad Request
2018-09-10 18:09:20.124321+0530 SmartKey[60090:8213025] LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server Bad Request"]
2018-09-10 18:09:20.125040+0530 SmartKey[60090:8213719] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=YA92qtD5hNZRp8nmAALu
2018-09-10 18:09:20.186585+0530 SmartKey[60090:8213903] LOG SocketEnginePolling: Got polling response
2018-09-10 18:09:20.186954+0530 SmartKey[60090:8213903] LOG SocketEnginePolling: Got poll message: Bad Request
2018-09-10 18:09:20.187404+0530 SmartKey[60090:8213903] LOG SocketEngine: Got message: Bad Request
2018-09-10 18:09:20.187998+0530 SmartKey[60090:8213025] ERROR SocketManager: Got unknown error from server Bad Request
2018-09-10 18:09:20.188256+0530 SmartKey[60090:8213025] LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server Bad Request"]
2018-09-10 18:09:20.188753+0530 SmartKey[60090:8213903] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=YA92qtD5hNZRp8nmAALu
2018-09-10 18:09:20.259055+0530 SmartKey[60090:8213719] LOG SocketEnginePolling: Got polling response
2018-09-10 18:09:20.259267+0530 SmartKey[60090:8213719] LOG SocketEnginePolling: Got poll message: Bad Request
2018-09-10 18:09:20.259619+0530 SmartKey[60090:8213719] LOG SocketEngine: Got message: Bad Request
2018-09-10 18:09:20.260364+0530 SmartKey[60090:8213025] ERROR SocketManager: Got unknown error from server Bad Request
2018-09-10 18:09:20.260730+0530 SmartKey[60090:8213025] LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server Bad Request"]
2018-09-10 18:09:20.261395+0530 SmartKey[60090:8213719] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=YA92qtD5hNZRp8nmAALu
2018-09-10 18:09:20.323531+0530 SmartKey[60090:8213719] LOG SocketEnginePolling: Got polling response
2018-09-10 18:09:20.323726+0530 SmartKey[60090:8213719] LOG SocketEnginePolling: Got poll message: Bad Request
2018-09-10 18:09:20.324038+0530 SmartKey[60090:8213719] LOG SocketEngine: Got message: Bad Request
2018-09-10 18:09:20.324347+0530 SmartKey[60090:8213025] ERROR SocketManager: Got unknown error from server Bad Request
2018-09-10 18:09:20.324568+0530 SmartKey[60090:8213025] LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server Bad Request"]
2018-09-10 18:09:20.325297+0530 SmartKey[60090:8213719] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=YA92qtD5hNZRp8nmAALu
2018-09-10 18:09:20.384588+0530 SmartKey[60090:8213903] LOG SocketEnginePolling: Got polling response
2018-09-10 18:09:20.384788+0530 SmartKey[60090:8213903] LOG SocketEnginePolling: Got poll message: Bad Request
2018-09-10 18:09:20.385383+0530 SmartKey[60090:8213903] LOG SocketEngine: Got message: Bad Request
2018-09-10 18:09:20.385928+0530 SmartKey[60090:8213025] ERROR SocketManager: Got unknown error from server Bad Request
2018-09-10 18:09:20.386189+0530 SmartKey[60090:8213025] LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server Bad Request"]
2018-09-10 18:09:20.386352+0530 SmartKey[60090:8213903] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=YA92qtD5hNZRp8nmAALu
2018-09-10 18:09:20.448346+0530 SmartKey[60090:8213719] LOG SocketEnginePolling: Got polling response
2018-09-10 18:09:20.448549+0530 SmartKey[60090:8213719] LOG SocketEnginePolling: Got poll message: Bad Request
2018-09-10 18:09:20.449189+0530 SmartKey[60090:8213719] LOG SocketEngine: Got message: Bad Request
2018-09-10 18:09:20.449655+0530 SmartKey[60090:8213025] ERROR SocketManager: Got unknown error from server Bad Request
2018-09-10 18:09:20.449905+0530 SmartKey[60090:8213025] LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server Bad Request"]
2018-09-10 18:09:20.450119+0530 SmartKey[60090:8213719] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=YA92qtD5hNZRp8nmAALu
Here is my code on initial setup and I am emitting the event after I make sure socket is connected.
let manager = SocketManager(socketURL: URL(string: "http://smartkey.trackagps.com:8888")!,config: [.log(true),.connectParams([:])]) var socket:SocketIOClient!
override init() {
super.init()
self.socket = manager.defaultSocket;
self.socket.joinNamespace() // Create a socket for the /swift namespac
}
This happens on app goes to background and coming back to foreground
Are you using load balancing? You might have to set the forceNew config option to force a new engine for reconnecting, since by default it will try to reuse the previous session id.
I am not using load balancing. This happens every time I go to background on my iOS device and launching once again.
Pasting once again the error response
2018-09-10 18:53:40.690869+0530 SmartKey[60310:8239983] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=TTCY-wrci4QpVAe5AAbZ
2018-09-10 18:53:43.962437+0530 SmartKey[60310:8239909] [Snapshotting] Snapshotting a view (0x142829e00, UIKeyboardImpl) that is not in a visible window requires afterScreenUpdates:YES.
2018-09-10 18:53:47.078641+0530 SmartKey[60310:8239984] TIC Read Status [3:0x1c017e540]: 1:57
2018-09-10 18:53:47.205093+0530 SmartKey[60310:8240272] LOG SocketEnginePolling: Got polling response
2018-09-10 18:53:47.205296+0530 SmartKey[60310:8240272] LOG SocketEnginePolling: Got poll message: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>500 - Internal server error.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
2018-09-10 18:53:47.206385+0530 SmartKey[60310:8240272] LOG SocketEngine: Got message: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>500 - Internal server error.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
<div class="
2018-09-10 18:53:47.208366+0530 SmartKey[60310:8239909] ERROR SocketManager: Got unknown error from server <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>500 - Internal server error.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="cont
2018-09-10 18:53:47.208553+0530 SmartKey[60310:8240272] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=TTCY-wrci4QpVAe5AAbZ
2018-09-10 18:53:47.211164+0530 SmartKey[60310:8239909] LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"/>\r\n<title>500 - Internal server error.</title>\r\n<style type=\"text/css\">\r\n<!--\r\nbody{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}\r\nfieldset{padding:0 15px 10px 15px;} \r\nh1{font-size:2.4em;margin:0;color:#FFF;}\r\nh2{font-size:1.7em;margin:0;color:#CC0000;} \r\nh3{font-size:1.2em;margin:10px 0 0 0;color:#000000;} \r\n#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:\"trebuchet MS\", Verdana, sans-serif;color:#FFF;\r\nbackground-color:#555555;}\r\n#content{margin:0 0 0 2%;position:relative;}\r\n.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}\r\n-->\r\n<
2018-09-10 18:53:47.265563+0530 SmartKey[60310:8240272] LOG SocketEnginePolling: Got polling response
2018-09-10 18:53:47.265687+0530 SmartKey[60310:8240272] LOG SocketEnginePolling: Got poll message: Bad Request
2018-09-10 18:53:47.265892+0530 SmartKey[60310:8240272] LOG SocketEngine: Got message: Bad Request
2018-09-10 18:53:47.267739+0530 SmartKey[60310:8239909] ERROR SocketManager: Got unknown error from server Bad Request
2018-09-10 18:53:47.267884+0530 SmartKey[60310:8239909] LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server Bad Request"]
2018-09-10 18:53:47.269811+0530 SmartKey[60310:8240272] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=TTCY-wrci4QpVAe5AAbZ
2018-09-10 18:53:47.328759+0530 SmartKey[60310:8239985] LOG SocketEnginePolling: Got polling response
2018-09-10 18:53:47.329011+0530 SmartKey[60310:8239985] LOG SocketEnginePolling: Got poll message: Bad Request
2018-09-10 18:53:47.329245+0530 SmartKey[60310:8239985] LOG SocketEngine: Got message: Bad Request
2018-09-10 18:53:47.329485+0530 SmartKey[60310:8239909] ERROR SocketManager: Got unknown error from server Bad Request
2018-09-10 18:53:47.329616+0530 SmartKey[60310:8239909] LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server Bad Request"]
2018-09-10 18:53:47.329909+0530 SmartKey[60310:8239985] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=TTCY-wrci4QpVAe5AAbZ
2018-09-10 18:53:47.426224+0530 SmartKey[60310:8239985] LOG SocketEnginePolling: Got polling response
2018-09-10 18:53:47.426348+0530 SmartKey[60310:8239985] LOG SocketEnginePolling: Got poll message: Bad Request
2018-09-10 18:53:47.426557+0530 SmartKey[60310:8239985] LOG SocketEngine: Got message: Bad Request
2018-09-10 18:53:47.426719+0530 SmartKey[60310:8239909] ERROR SocketManager: Got unknown error from server Bad Request
2018-09-10 18:53:47.426827+0530 SmartKey[60310:8239909] LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server Bad Request"]
2018-09-10 18:53:47.427218+0530 SmartKey[60310:8239985] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=TTCY-wrci4QpVAe5AAbZ
2018-09-10 18:53:47.487450+0530 SmartKey[60310:8239984] LOG SocketEnginePolling: Got polling response
2018-09-10 18:53:47.487804+0530 SmartKey[60310:8239984] LOG SocketEnginePolling: Got poll message: Bad Request
2018-09-10 18:53:47.488007+0530 SmartKey[60310:8239984] LOG SocketEngine: Got message: Bad Request
2018-09-10 18:53:47.488553+0530 SmartKey[60310:8239909] ERROR SocketManager: Got unknown error from server Bad Request
2018-09-10 18:53:47.488733+0530 SmartKey[60310:8239909] LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server Bad Request"]
2018-09-10 18:53:47.489021+0530 SmartKey[60310:8239984] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=TTCY-wrci4QpVAe5AAbZ
2018-09-10 18:53:47.552295+0530 SmartKey[60310:8240138] LOG SocketEnginePolling: Got polling response
2018-09-10 18:53:47.552504+0530 SmartKey[60310:8240138] LOG SocketEnginePolling: Got poll message: Bad Request
2018-09-10 18:53:47.553197+0530 SmartKey[60310:8240138] LOG SocketEngine: Got message: Bad Request
2018-09-10 18:53:47.553532+0530 SmartKey[60310:8239909] ERROR SocketManager: Got unknown error from server Bad Request
2018-09-10 18:53:47.553755+0530 SmartKey[60310:8239909] LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server Bad Request"]
2018-09-10 18:53:47.554259+0530 SmartKey[60310:8240138] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=TTCY-wrci4QpVAe5AAbZ
2018-09-10 18:53:47.614383+0530 SmartKey[60310:8240272] LOG SocketEnginePolling: Got polling response
2018-09-10 18:53:47.614501+0530 SmartKey[60310:8240272] LOG SocketEnginePolling: Got poll message: Bad Request
2018-09-10 18:53:47.614657+0530 SmartKey[60310:8240272] LOG SocketEngine: Got message: Bad Request
2018-09-10 18:53:47.614903+0530 SmartKey[60310:8239909] ERROR SocketManager: Got unknown error from server Bad Request
2018-09-10 18:53:47.614995+0530 SmartKey[60310:8239909] LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server Bad Request"]
2018-09-10 18:53:47.615337+0530 SmartKey[60310:8240272] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=TTCY-wrci4QpVAe5AAbZ
Have you tried forceNew? This log isn't very helpful, since it looks like the server is returning a 500. Also, if you're using iOS, it's probably worth disabling automatic reconnecting and explicitly handle creating/reconnecting yourself. iOS doesn't play nicely with background connections, especially with this library.
Hi I just did the following
- I connected the socket when app launches.
- I went to background and not disconnected the socket.
- When app comes to foreground, I am trying to re connect back only if status is not connected.
static let sharedInstance = SocketIOManager()
let manager = SocketManager(socketURL: URL(string: "http://smartkey.trackagps.com:8888")!,config: [.log(true),.reconnects(false),.connectParams([:])])
var socket:SocketIOClient!
override init() {
super.init()
self.socket = manager.defaultSocket;
socket.joinNamespace() // Create a socket for the /swift namespac
}
func connectAppToSocket(callBack : @escaping onSuccessCallBack) {
if socket.status != SocketIOStatus.connected {
socket.connect()
socket.on(clientEvent: .connect) {data, ack in
print("socket connected")
callBack(true)
}
}else {
callBack(true)
}
}
Here I am getting infinite logs as below
2018-09-11 00:13:19.574877+0530 SmartKey[61566:8368405] LOG SocketEnginePolling: Got polling response
2018-09-11 00:13:19.575039+0530 SmartKey[61566:8368405] LOG SocketEnginePolling: Got poll message: Bad Request
2018-09-11 00:13:19.575251+0530 SmartKey[61566:8368405] LOG SocketEngine: Got message: Bad Request
2018-09-11 00:13:19.575477+0530 SmartKey[61566:8368282] ERROR SocketManager: Got unknown error from server Bad Request
2018-09-11 00:13:19.575629+0530 SmartKey[61566:8368282] LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server Bad Request"]
2018-09-11 00:13:19.577097+0530 SmartKey[61566:8368405] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=IKRtZmZ80bhe1r7VAAAC
I am not doing any thing extra. In Android it is working fine. Please let me know if I am doing anything wrong in swift.
Have you tried adding the .forceNew(true) config? Also you shouldn't need to call .joinNamespace(), it's probably best to use the manager to control the sockets.
Hi I tried .forceNew(true)
This time scenario as follows
-
Connect to socket on first launch
-
Disconnect on going to background
-
Wait for 5 seconds and come to foreground and try to connect once again
static let sharedInstance = SocketIOManager()
let manager = SocketManager(socketURL: URL(string: "http://smartkey.trackagps.com:8888")!,config: [.log(true),.reconnects(true), .forceNew(true),.connectParams([:])])
var socket:SocketIOClient!
override init() {
super.init()
self.socket = manager.defaultSocket;
}
func connectAppToSocket(callBack : @escaping onSuccessCallBack) {
if self.socket.status != SocketIOStatus.connected {
self.socket = manager.defaultSocket;
self.socket.connect()
self.socket.on(clientEvent: .connect) {data, ack in
print("socket connected")
callBack(true)
}
}else {
callBack(true)
}
}
Getting same infinite error
LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server \r\n<html xmlns="http://www.w3.org/1999/xhtml">\r\n
\r\n<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>\r\n
2018-09-11 02:02:58.749603+0530 SmartKey[62070:8415800] LOG SocketEnginePolling: Got polling response 2018-09-11 02:02:58.749768+0530 SmartKey[62070:8415800] LOG SocketEnginePolling: Got poll message: Bad Request 2018-09-11 02:02:58.750053+0530 SmartKey[62070:8415800] LOG SocketEngine: Got message: Bad Request 2018-09-11 02:02:58.750348+0530 SmartKey[62070:8415539] ERROR SocketManager: Got unknown error from server Bad Request 2018-09-11 02:02:58.750463+0530 SmartKey[62070:8415539] LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server Bad Request"] 2018-09-11 02:02:58.750472+0530 SmartKey[62070:8415800] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=v2NSxG32vxcvsihEAAAE
If I mention .reconnects(false) on second time when app comes to foreground, socket is not getting connected.
static let sharedInstance = SocketIOManager()
let manager = SocketManager(socketURL: URL(string: "http://smartkey.trackagps.com:8888")!,config: [.log(true),.reconnects(false), .forceNew(true)])
var socket:SocketIOClient!
override init() {
super.init()
self.socket = manager.defaultSocket;
}
2018-09-11 02:14:41.562924+0530 SmartKey[62122:8420450] LOG SocketIOClient{/}: Closing socket
2018-09-11 02:14:41.566127+0530 SmartKey[62122:8420450] LOG SocketIOClient{/}: Disconnected: Disconnect
2018-09-11 02:14:41.566211+0530 SmartKey[62122:8420450] LOG SocketIOClient{/}: Handling event: statusChange with data: [disconnected]
2018-09-11 02:14:41.566398+0530 SmartKey[62122:8420450] LOG SocketIOClient{/}: Handling event: disconnect with data: ["Disconnect"]
2018-09-11 02:14:48.084824+0530 SmartKey[62122:8420450] LOG SocketIOClient{/}: Handling event: statusChange with data: [connecting]
2018-09-11 02:14:48.084965+0530 SmartKey[62122:8420450] LOG SocketIOClient{/}: Adding handler for event: connect
2018-09-11 02:14:48.085891+0530 SmartKey[62122:8420531] LOG SocketEngine: Writing poll: 0/ has data: false
2018-09-11 02:14:48.085943+0530 SmartKey[62122:8420531] LOG SocketEnginePolling: Sending poll: 0/ as type: 4
2018-09-11 02:14:48.085993+0530 SmartKey[62122:8420531] LOG SocketEnginePolling: Created POST string: 3:40/
2018-09-11 02:14:48.086260+0530 SmartKey[62122:8420531] LOG SocketEnginePolling: POSTing
2018-09-11 02:14:48.086318+0530 SmartKey[62122:8420531] LOG SocketEnginePolling: Doing polling POST http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=WmrDpYMpu9fBLs22AAAG
2018-09-11 02:14:48.113929+0530 SmartKey[62122:8420534] TIC Read Status [1:0x1c416f240]: 1:57
2018-09-11 02:14:48.114401+0530 SmartKey[62122:8420534] Returning ENOTCONN because protocol has not yet been set up
2018-09-11 02:14:57.977757+0530 SmartKey[62122:8420450] LOG SocketIOClient{/}: Handling event: ping with data: []
2018-09-11 02:14:57.978229+0530 SmartKey[62122:8420531] LOG SocketEngine: Writing poll: has data: false
2018-09-11 02:14:57.978346+0530 SmartKey[62122:8420531] LOG SocketEnginePolling: Sending poll: as type: 2
2018-09-11 02:14:57.978785+0530 SmartKey[62122:8420531] LOG SocketEnginePolling: Created POST string: 1:2
2018-09-11 02:14:57.979313+0530 SmartKey[62122:8420531] LOG SocketEnginePolling: POSTing
2018-09-11 02:14:57.979466+0530 SmartKey[62122:8420531] LOG SocketEnginePolling: Doing polling POST http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=WmrDpYMpu9fBLs22AAAG
2018-09-11 02:14:58.060229+0530 SmartKey[62122:8420534] LOG SocketEnginePolling: Got polling response
2018-09-11 02:14:58.060539+0530 SmartKey[62122:8420534] LOG SocketEnginePolling: Got poll message: 1:3
2018-09-11 02:14:58.061191+0530 SmartKey[62122:8420534] LOG SocketEngine: Got message: 3
2018-09-11 02:14:58.061471+0530 SmartKey[62122:8420450] LOG SocketIOClient{/}: Handling event: pong with data: []
2018-09-11 02:14:58.062091+0530 SmartKey[62122:8420534] LOG SocketEnginePolling: Doing polling GET http://smartkey.trackagps.com:8888/socket.io/?transport=polling&b64=1&sid=WmrDpYMpu9fBLs22AAAG
Right .reconnects(false) means you will have to manage the connectivity of the socket. The most bulletproof way to handle that is just to recreate a socket when the app comes back into the foreground. [.reconnects(true), .forceNew(true)] might work for you though. btw I'm basing all this on the assumption that something in your server doesn't like the sid being present. Otherwise you would need to find out why the server is returning a bad request.
HI, I reverted my code to Swift 11.1.0 and disconnecting socket on every time I tried to connect back. It works fine now. My observation is, I was getting above infinite logs because of trying to connect socket when it is already connected.
@Pradeepkn Is this resolved or?
It is resolved. Thanks for your suggestions.
Regards, Pradeep K N
On 11-Sep-2018, at 11:30 PM, Erik Little [email protected] wrote:
@Pradeepkn Is this resolved or?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.