nuclearace / Socket.IO-Client-Swift

socket.io-client for Swift
Other
361 stars 53 forks source link

fatal error: cannot increment beyond endIndex #136

Open utdrmac opened 7 years ago

utdrmac commented 7 years ago

Hello. Testing this our for the first time. Swift 3 / Xcode 8.1. I'm trying to connect to the wikimedia recentchanges socket. Finally figured out the correct .path() and then I got this fatal error.

let socket = SocketIOClient(socketURL: URL(string: "wc://stream.wikimedia.org/")!, 
   config: [.path("/socket.io/1/"), .log(true), .forcePolling(true)])

socket.on("connect")
{
  data, ack in
  print("socket connected")
}

socket.on("currentAmount")
{
  data, ack in
  print ("Got data: \(data)")
}
socket.connect()

Fatal error occurred on the first line of this method.

_SocketStringReader.swift_
mutating func read(count: Int) -> String {
        let readString = message[currentIndex..<message.characters.index(currentIndex, offsetBy: count)]

        advance(by: count)

        return readString
    }
2016-12-07 09:16:22.673750 ongaku[69358:6208231] fatal error: cannot increment beyond endIndex
Current stack trace:
0    libswiftCore.dylib                 0x000000010044fcc0 swift_reportError + 132
1    libswiftCore.dylib                 0x000000010046d070 _swift_stdlib_reportFatalError + 61
2    libswiftCore.dylib                 0x00000001002630a0 specialized specialized StaticString.withUTF8Buffer<A> ((UnsafeBufferPointer<UInt8>) -> A) -> A + 355
3    libswiftCore.dylib                 0x00000001003df210 partial apply for (_fatalErrorMessage(StaticString, StaticString, StaticString, UInt, flags : UInt32) -> Never).(closure #2) + 109
4    libswiftCore.dylib                 0x00000001002630a0 specialized specialized StaticString.withUTF8Buffer<A> ((UnsafeBufferPointer<UInt8>) -> A) -> A + 355
5    libswiftCore.dylib                 0x00000001003973d0 specialized _fatalErrorMessage(StaticString, StaticString, StaticString, UInt, flags : UInt32) -> Never + 96
6    libswiftCore.dylib                 0x000000010039d4f0 specialized String.CharacterView.index(after : String.CharacterView.Index) -> String.CharacterView.Index + 170
7    libswiftCore.dylib                 0x0000000100355d10 protocol witness for IndexableBase.formIndex(after : inout A.Index) -> () in conformance String.CharacterView + 68
8    libswiftCore.dylib                 0x00000001002647a0 Indexable._advanceForward(A.Index, by : A.IndexDistance) -> A.Index + 2202
9    libswiftCore.dylib                 0x0000000100263d20 BidirectionalIndexable.index(A.Index, offsetBy : A.IndexDistance) -> A.Index + 781
10   ongaku                             0x0000000100035860 SocketStringReader.read(count : Int) -> String + 307
11   ongaku                             0x00000001000628f0 SocketEnginePollable.parsePollingMessage(String) -> () + 610
12   ongaku                             0x0000000100062870 SocketEnginePollable.(doLongPoll(for : URLRequest) -> ()).(closure #1).(closure #1) + 89
13   ongaku                             0x0000000100062ed0 _TTRgRx6ongaku20SocketEnginePollablerXFo___XFdCb___ + 39
14   libdispatch.dylib                  0x0000000100b17741 _dispatch_call_block_and_release + 12
15   libdispatch.dylib                  0x0000000100b0dfc4 _dispatch_client_callout + 8
16   libdispatch.dylib                  0x0000000100b25a3e _dispatch_queue_serial_drain + 205
17   libdispatch.dylib                  0x0000000100b1705b _dispatch_queue_invoke + 1174
18   libdispatch.dylib                  0x0000000100b1e4df _dispatch_queue_override_invoke + 656
19   libdispatch.dylib                  0x0000000100b0ffa8 _dispatch_root_queue_drain + 671
20   libdispatch.dylib                  0x0000000100b0fee6 _dispatch_worker_thread3 + 114
21   libsystem_pthread.dylib            0x0000000100b853af _pthread_wqthread + 1299
22   libsystem_pthread.dylib            0x0000000100b85390 start_wqthread + 13
utdrmac commented 7 years ago

Ohh. This may be an issue with socket.io v0.9. I think my source is running an older version.

utdrmac commented 7 years ago

Is there a Swift3 socket.io library that supports socket.io-v0.9?