-
-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It not able to connect web socket. #13
Comments
Hello @hukusuke1007 , |
@WrathChaos But it not called override method. ・Additional infomation.
■Log. |
@hukusuke1007 Okey, I will try to get data from your socket. Do I need any other information to connect your socket url? |
@hukusuke1007 Hello again,
These lines on the example and try it :) |
@WrathChaos I'm sorry for late. import UIKit
import StompClientLib
class ViewController: UIViewController, StompClientLibDelegate {
private var socketClient_:StompClientLib!
override func viewDidLoad() {
super.viewDidLoad()
//getXemByJpyFromZaif_()
socketClient_ = StompClientLib()
RegisterSocket()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
public func RegisterSocket() {
let baseURL = "http://alice2.nem.ninja:7778/w/messages/websocket"
let completedWSURL = baseURL
print("URL : \(completedWSURL)")
let url = NSURL(string: completedWSURL)!
socketClient_.openSocketWithURLRequest(request: NSURLRequest(url: url as URL) , delegate: self)
}
// ■ MARK: delegate.
func stompClientDidConnect(client: StompClientLib!) {
let info = mySecretInfo()
// ■ Subscribe.
let topic = "/blocks/new" // OK
let header = ["id":"0"]
print("Subscrib : \(topic)")
client.subscribeWithHeader(destination: topic, withHeader: header)
// ■ Send.
let sendTopic = "/w/api/account/mosaic/owned/"
let sendData = ["account":"NCH5JDPEAKA3CKQBSEPE4VIH53FQO4AU55XTVRPY"]
print("Send topic : \(sendTopic)")
client.sendJSONForDict(dict: sendData as AnyObject, toDestination: sendTopic)
}
func stompClientDidDisconnect(client: StompClientLib!) {
print("Socket is Disconnected")
RegisterSocket()
}
func stompClientWillDisconnect(client: StompClientLib!, withError error: NSError) {
print("Socket is Disconnected error \(error)")
}
func stompClient(client: StompClientLib!, didReceiveMessageWithJSONBody jsonBody: AnyObject?, withHeader header: [String : String]?, withDestination destination: String) {
if let data = header {
data.forEach {print("\($0.0):\($0.1)") }
}
print("DESTIONATION : \(destination)")
print("JSON BODY : \(String(describing: jsonBody))")
}
func stompClientJSONBody(client: StompClientLib!, didReceiveMessageWithJSONBody jsonBody: String?, withHeader header: [String : String]?, withDestination destination: String) {
print("stompClientJSONBody")
//print("DESTIONATION : \(destination)")
//print("String JSON BODY : \(String(describing: jsonBody))")
}
func serverDidSendReceipt(client: StompClientLib!, withReceiptId receiptId: String) {
print("Receipt : \(receiptId)")
}
func serverDidSendError(client: StompClientLib!, withErrorMessage description: String, detailedErrorMessage message: String?) {
print("Error : \(description) \(String(describing: message))")
}
func serverDidSendPing() {
print("Server Ping")
}
} |
@hukusuke1007 Sorry for very late response, had a tough week. |
@hukusuke1007 Could you solve your issue? |
@WrathChaos Sorry for very late response. Thank you for your advice. |
I have a problem.
It not able to connect web socket.
■Source code.
let baseURL = "http://alice2.nem.ninja:7890"
print("URL : (baseURL)")
let url = NSURL(string: baseURL)!
StompClientLib().openSocketWithURLRequest(request: NSURLRequest(url: url as URL) , delegate: self)
■Result
URL : http://alice2.nem.ninja:7890
2018-01-19 02:07:04.566143+0900 TestNem[35284:6662686] [MC] Lazy loading NSBundle MobileCoreServices.framework
2018-01-19 02:07:04.568846+0900 TestNem[35284:6662686] [MC] Loaded MobileCoreServices.framework
didFailWithError: Optional(Error Domain=SRWebSocketErrorDomain Code=2132 "received bad response code from server 404" UserInfo={NSLocalizedDescription=received bad response code from server 404, HTTPResponseStatusCode=404})
Error : Optional("received bad response code from server 404")
2018-01-19 02:08:05.167697+0900 TestNem[35284:6666614] [BoringSSL] Function boringssl_session_errorlog: line 2871 [boringssl_session_read] SSL_ERROR_ZERO_RETURN(6): operation failed because the connection was cleanly shut down with a close_notify alert
2018-01-19 02:08:05.168153+0900 TestNem[35284:6666614] [BoringSSL] Function boringssl_session_errorlog: line 2871 [boringssl_session_read] SSL_ERROR_ZERO_RETURN(6): operation failed because the connection was cleanly shut down with a close_notify alert
Is it need to set other parameter??
I want your advice.
Best regards.
The text was updated successfully, but these errors were encountered: