Skip to content

fatalError when trying to send a message using URLSessionWebSocketTask #4730

Closed
@LosFarmosCTL

Description

@LosFarmosCTL

Hey, I am trying to get a WebSocket connection running on Linux using FoundationNetworking, I am using the nightly-5.8-jammy docker image inside of a devcontainer:

Swift version 5.8-dev (LLVM f0fb631dd1a3a29, Swift ef7a6b85c8f7360)
Target: x86_64-unknown-linux-gnu

Everything compiles correctly but when I try to actually send a message (UPDATE: also happens when calling receive()), I get a fatalError, saying that the URL is invalid:

Swift/ErrorType.swift:200: Fatal error: Error raised at top level: Error Domain=NSURLErrorDomain Code=-1002 "(null)"
Current stack trace:
0    libswiftCore.so                    0x00007fda5194db10 _swift_stdlib_reportFatalErrorInFile + 112
1    libswiftCore.so                    0x00007fda5163f40f <unavailable> + 1442831
2    libswiftCore.so                    0x00007fda5163f227 <unavailable> + 1442343
3    libswiftCore.so                    0x00007fda5163e030 _assertionFailure(_:_:file:line:flags:) + 364
4    libswiftCore.so                    0x00007fda5169ce96 <unavailable> + 1826454
5    Test                               0x000055df55764eed <unavailable> + 57069
6    libswift_Concurrency.so            0x00007fda51b5d0ee <unavailable> + 274670
7    libswift_Concurrency.so            0x00007fda51b5d860 swift_job_run + 92
8    libdispatch.so                     0x00007fda51d9bf45 <unavailable> + 192325
9    libdispatch.so                     0x00007fda51d9cbbd <unavailable> + 195517
10   libdispatch.so                     0x00007fda51da4002 <unavailable> + 225282
11   libc.so.6                          0x00007fda5130ab43 <unavailable> + 609091
12   libc.so.6                          0x00007fda5139ca00 <unavailable> + 1206784
Illegal instruction (core dumped)

I attempt to connect to Twitch Chat, I've made a very simple test that just tries to send a single message to their server:

import Foundation

#if canImport(FoundationNetworking)
  import FoundationNetworking
#endif

@main public struct Test {
  public static func main() async throws {
    let url = URL(string: "wss://irc-ws.chat.twitch.tv:443")!

    let ws = URLSession.shared.webSocketTask(with: url)

    ws.resume()

    try await ws.send(.string("CAP REQ :twitch.tv/tags"))
  }
}

That code runs perfectly fine under macOS (using Swift 5.7), but as soon as it's run on Linux I get the error from above.

I've tried using different WebSocket URLs, but everything yields the same result.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions