Skip to content
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

The default JSON Encoder serialization doesn't work with SignalR Server for byte[] #304

Open
moozzyk opened this issue Jan 28, 2025 · 0 comments

Comments

@moozzyk
Copy link
Owner

moozzyk commented Jan 28, 2025

Binary payloads are by default translated to JSON array and rejected by the server. Example:

for i in 1...5 {
    // continuation.yield([UInt8(i)] // fails
    continuation.yield(Data([UInt8(i)]).base64EncodedString()) // workaround
    Thread.sleep(forTimeInterval: 0.1)
}

The workaround is to base64 encode the data before sending. Similarly, receiving the data as byte array won't work. It needs to be a string which the client needs to then base64 decode.

struct MessageSHA: Decodable {
    // let value: [UInt8] - doesn't work
    let value: String
    let shaType: Int
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant