I have a webpage that once the document is ready, starts a socket connection. The client only receives messages on a continuous basis and does not send any. I noticed an issue where if I refresh the page, I.E. closing the current socket and instantly opening a new one, I would get the error stated in the title on any attempts to send data to client.
This resolved the issue. FYI this was using Vapor 1. Not sure if something has already been put in place with Vapor 2 to handle this situation. Sample code I used is below.
I have a webpage that once the document is ready, starts a socket connection. The client only receives messages on a continuous basis and does not send any. I noticed an issue where if I refresh the page, I.E. closing the current socket and instantly opening a new one, I would get the error stated in the title on any attempts to send data to client.
Upon doing some research I found this example which locks onClose: https://github.com/IBM-Swift/Kitura-Chat-Server/blob/master/Sources/KituraChatServer/ChatService.swift
This resolved the issue. FYI this was using Vapor 1. Not sure if something has already been put in place with Vapor 2 to handle this situation. Sample code I used is below.