Closed Gdev82 closed 4 years ago
I've tried with my local example and it worked for me. Can you share with me a reproducible example?
My apologies for the late response, here is my setup
class WebSocketClientImpl: WebSocketClient {
let socketClient = StompClientLib()
init() {
socketClient.certificateCheckEnabled = false
}
func connectToWebSocket() {
guard let connectReuest = WebSocketRequest.connect.asUrlRequest() else {
return
}
socketClient.openSocketWithURLRequest(request: connectReuest as NSURLRequest, delegate: self)
}
func reconnect() {
guard let connectRequest = WebSocketRequest.connect.asUrlRequest() else {
return
}
socketClient.reconnect(request: connectRequest as NSURLRequest, delegate: self, connectionHeaders: [:], time: 4, exponentialBackoff: false)
}
}
extension WebSocketClientImpl:StompClientLibDelegate {
func stompClient(client: StompClientLib!, didReceiveMessageWithJSONBody jsonBody: AnyObject?, akaStringBody stringBody: String?, withHeader header: [String : String]?, withDestination destination: String) {
print("got json", jsonBody, stringBody, destination)
}
func stompClientDidDisconnect(client: StompClientLib!) {
print("disconected from websocket")
socketClient.unsubscribe(destination: "<destination>")
}
func stompClientDidConnect(client: StompClientLib!) {
print("connected to websocket..")
socketClient.subscribe(destination: "<destination>")
reconnect()
}
func serverDidSendReceipt(client: StompClientLib!, withReceiptId receiptId: String) {
}
func serverDidSendError(client: StompClientLib!, withErrorMessage description: String, detailedErrorMessage message: String?) {
print("got error", description, message)
}
func serverDidSendPing() {
}
}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hi again, did you get a chance to look at this issue?
Thank you in advance.
George
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hey @Gdev82 Have you ever tried this problem with the latest version of StompClientLib? And sorry for the late response, totally forgot about it :(
Hi,
Thank you for this library, working great.
A few days ago, and I wanted to incorporate the reconnect option of this library in case for example the server goes down.
What I noticed is that when the method
webSocket(_ webSocket: SRWebSocket!, didCloseWithCode code: Int, reason: String!, wasClean: Bool)
it does not close the connection. As a result when reconnect is called it never reaches the open connection block since it checks if the connection is open.if (!self.isConnected()){ self.checkConnectionHeader(connectionHeaders: connectionHeaders) ? self.openSocketWithURLRequest(request: request, delegate: delegate, connectionHeaders: connectionHeaders) : self.openSocketWithURLRequest(request: request, delegate: delegate) }
Am I missing something? Do I have to set the flag manually at that point?
Thank you
George