RxStarscream icon indicating copy to clipboard operation
RxStarscream copied to clipboard

Disconnected with optional error : "Connection refused"

Open azeemohd786 opened this issue 4 years ago • 0 comments

When I tried to run the sample project with just basics to connect web socket, getting this error -Disconnected with optional error : Optional(Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused"

@_exported import RxSwift
@_exported import RxStarscream
import Starscream

  override func viewDidLoad() {
        super.viewDidLoad()
 private let disposeBag = DisposeBag()
 
socket = WebSocket(url: URL(string: "ws://localhost:8080/")!)
        socket.connect()

 socket.rx.response.subscribe(onNext: { (response: WebSocketEvent) in
            switch response {
            case .connected:
                print("Connected")
            case .disconnected(let error):
                print("Disconnected with optional error : \(error)")
            case .message(let msg):
                print("Message : \(msg)")
            case .data(_):
                print("Data")
            case .pong:
                print("Pong")
            }
        }).disposed(by: disposeBag)
}

am I doing anything wrong, I could find the solution..

azeemohd786 avatar Nov 12 '20 15:11 azeemohd786