I do not know how to get rid of the Idle connection error. It used to be worse, but still it happened every hour or so. Here is the log I get with Papertrail:
Aug 09 23:07:25 heroku/router: at=info method=GET path="/a/login/" host=... request_id=f99431f8-9ce9-4e1e-b16f-0ae2b50870ab fwd="74.210.150.28" dyno=web.1 connect=1ms service=258ms status=304 bytes=305 Aug 09 23:07:26 heroku/router: at=info method=GET path="/js/auth.js" host=app.sofiatutors.com request_id=12896c98-9803-4161-bf5b-06028123ff86 fwd="74.210.150.28" dyno=web.1 connect=2ms service=3ms status=304 bytes=240 Aug 09 23:07:56 heroku/router: at=info method=POST path="/api/email/reset/qEUsZwkRvp750OBgCFuXImiCWPhQbTD0vFVaGEyCZJJXEJGpm6Gi7cgKWsLqHOTusRHieWyVgEbqe6T5qH7wCJT9ROToeHnINhTDvq5unWT6r7fwh4ha59PlQVwB6TmS" host=app.sofiatutors.com request_id=ae44cd3d-cb06-42bd-8948-9e8ca8273ebe fwd="74.210.150.28" dyno=web.1 connect=1ms service=395ms status=200 bytes=426 Aug 09 23:08:11 heroku/router: at=info method=POST path="/api/email/reset/qEUsZwkRvp750OBgCFuXImiCWPhQbTD0vFVaGEyCZJJXEJGpm6Gi7cgKWsLqHOTusRHieWyVgEbqe6T5qH7wCJT9ROToeHnINhTDvq5unWT6r7fwh4ha59PlQVwB6TmS" host=app.sofiatutors.com request_id=a0ed9edc-a561-4518-a61c-3d22fa9445aa fwd="74.210.150.28" dyno=web.1 connect=0ms service=214ms status=200 bytes=426 Aug 09 23:08:21 heroku/router: at=error code=H15 desc="Idle connection" method=GET path="/socket.io/?EIO=3&transport=websocket" host=app.sofiatutors.com request_id=a5db86f2-7561-44db-bc1d-22ae69ac3a30 fwd="74.210.150.28" dyno=web.1 connect=1ms service=56301ms status=503 bytes=279 method = POST path = "/ api / email / reset / qEUsZwkRvp750OBgCFuXImiCWPhQbTD0vFVaGEyCZJJXEJGpm6Gi7cgKWsLqHOTusRHieWyVgEbqe6T5qH7wCJT9ROToeHnINhTDvq5unWT6r7fwh4ha59PlQVwB6TmS" host = app.sofiatutors.com request_id = ae44cd3d-cb06-42bd-8948-9e8ca8273ebe fwd = " Aug 09 23:07:25 heroku/router: at=info method=GET path="/a/login/" host=... request_id=f99431f8-9ce9-4e1e-b16f-0ae2b50870ab fwd="74.210.150.28" dyno=web.1 connect=1ms service=258ms status=304 bytes=305 Aug 09 23:07:26 heroku/router: at=info method=GET path="/js/auth.js" host=app.sofiatutors.com request_id=12896c98-9803-4161-bf5b-06028123ff86 fwd="74.210.150.28" dyno=web.1 connect=2ms service=3ms status=304 bytes=240 Aug 09 23:07:56 heroku/router: at=info method=POST path="/api/email/reset/qEUsZwkRvp750OBgCFuXImiCWPhQbTD0vFVaGEyCZJJXEJGpm6Gi7cgKWsLqHOTusRHieWyVgEbqe6T5qH7wCJT9ROToeHnINhTDvq5unWT6r7fwh4ha59PlQVwB6TmS" host=app.sofiatutors.com request_id=ae44cd3d-cb06-42bd-8948-9e8ca8273ebe fwd="74.210.150.28" dyno=web.1 connect=1ms service=395ms status=200 bytes=426 Aug 09 23:08:11 heroku/router: at=info method=POST path="/api/email/reset/qEUsZwkRvp750OBgCFuXImiCWPhQbTD0vFVaGEyCZJJXEJGpm6Gi7cgKWsLqHOTusRHieWyVgEbqe6T5qH7wCJT9ROToeHnINhTDvq5unWT6r7fwh4ha59PlQVwB6TmS" host=app.sofiatutors.com request_id=a0ed9edc-a561-4518-a61c-3d22fa9445aa fwd="74.210.150.28" dyno=web.1 connect=0ms service=214ms status=200 bytes=426 Aug 09 23:08:21 heroku/router: at=error code=H15 desc="Idle connection" method=GET path="/socket.io/?EIO=3&transport=websocket" host=app.sofiatutors.com request_id=a5db86f2-7561-44db-bc1d-22ae69ac3a30 fwd="74.210.150.28" dyno=web.1 connect=1ms service=56301ms status=503 bytes=279 method = POST path = "/ api / email / reset / qEUsZwkRvp750OBgCFuXImiCWPhQbTD0vFVaGEyCZJJXEJGpm6Gi7cgKWsLqHOTusRHieWyVgEbqe6T5qH7wCJT9ROToeHnINhTDvq5unWT6r7fwh4ha59PlQVwB6TmS" host = app.sofiatutors.com request_id = a0ed9edc-a561-4518-a61c-3d22fa9445aa fwd = " Aug 09 23:07:25 heroku/router: at=info method=GET path="/a/login/" host=... request_id=f99431f8-9ce9-4e1e-b16f-0ae2b50870ab fwd="74.210.150.28" dyno=web.1 connect=1ms service=258ms status=304 bytes=305 Aug 09 23:07:26 heroku/router: at=info method=GET path="/js/auth.js" host=app.sofiatutors.com request_id=12896c98-9803-4161-bf5b-06028123ff86 fwd="74.210.150.28" dyno=web.1 connect=2ms service=3ms status=304 bytes=240 Aug 09 23:07:56 heroku/router: at=info method=POST path="/api/email/reset/qEUsZwkRvp750OBgCFuXImiCWPhQbTD0vFVaGEyCZJJXEJGpm6Gi7cgKWsLqHOTusRHieWyVgEbqe6T5qH7wCJT9ROToeHnINhTDvq5unWT6r7fwh4ha59PlQVwB6TmS" host=app.sofiatutors.com request_id=ae44cd3d-cb06-42bd-8948-9e8ca8273ebe fwd="74.210.150.28" dyno=web.1 connect=1ms service=395ms status=200 bytes=426 Aug 09 23:08:11 heroku/router: at=info method=POST path="/api/email/reset/qEUsZwkRvp750OBgCFuXImiCWPhQbTD0vFVaGEyCZJJXEJGpm6Gi7cgKWsLqHOTusRHieWyVgEbqe6T5qH7wCJT9ROToeHnINhTDvq5unWT6r7fwh4ha59PlQVwB6TmS" host=app.sofiatutors.com request_id=a0ed9edc-a561-4518-a61c-3d22fa9445aa fwd="74.210.150.28" dyno=web.1 connect=0ms service=214ms status=200 bytes=426 Aug 09 23:08:21 heroku/router: at=error code=H15 desc="Idle connection" method=GET path="/socket.io/?EIO=3&transport=websocket" host=app.sofiatutors.com request_id=a5db86f2-7561-44db-bc1d-22ae69ac3a30 fwd="74.210.150.28" dyno=web.1 connect=1ms service=56301ms status=503 bytes=279
At first, I thought that this was due to the fact that the user uploaded a file or something like that, but it is not. From what I see, the user simply reloads his password. What's even weirder, since WebSocket is not currently in use, except for ping-pong!
I did not find any solutions on the Internet. I am using a CNAME record for my DNS. I maintain a connection by sending ping to my server, which responds via pong every 20 seconds using my WebSocket. I force a connection to WebSocket in Socket.io (I got more free connections with XHR polling).
This is my client code :
const socket_url = environment.indexOf('dev') === -1 ? "wss://" + window.location.host : 'ws://localhost:3000'; var socket = io.connect(socket_url, { transports : ["websocket"] }); let socketIoMiddleware = createSocketIoMiddleware(socket, "server/"); socket.on('connect', function() { console.log("L'utilisateur s'est connecté à un Socket."); // Init code }); socket.on('disconnect', function(){ console.log("Déconnexion au socket.") }); socket.emit('ping'); socket.on('pong', function() { console.log("pong", new Date().toString()); var to = setTimeout(function(){ console.log("ping", new Date().toString()); socket.emit('ping'); clearTimeout(to) },20000); });
And my server code (Node.JS with Express):
io.sockets.on('connection', function (socket) { socket.on('join-auth', function (data) { socket.join(data.session); // We are using room of socket io var room = data.session; socket.on('ping', function(){ // console.log("ping pong", new Date().toString()) io.sockets.in(room).emit('pong'); }) // The rest of my socket
I know Heroku has a 55 second timeout for WebSockets, but I just don't understand why the connection is idle or how to fix it. Does anyone have an idea?