Coder Social home page Coder Social logo

Comments (11)

Lukasa avatar Lukasa commented on June 12, 2024 1

The other thing you can try to do to debug this is to get a packet capture of the two different handshakes.

from swift-nio.

Lukasa avatar Lukasa commented on June 12, 2024

The websocket key (in Sec-Websocket-Key) is set by the client, not the server. It's typically generated randomly, but the server has no influence over it: it can only compute over it. Is it the case that the client repeatedly connect to the Xcode-built server, but not the Bazel-built server? Does it always fail to connect to the Bazel server?

from swift-nio.

luispadron avatar luispadron commented on June 12, 2024

@Lukasa correct, the client is able to always connect to the server (macOS app) when the server is built with Xcode but handshake always fails when I build the server with Bazel

from swift-nio.

Lukasa avatar Lukasa commented on June 12, 2024

Does this reproduce with the sample servers in this repo?

from swift-nio.

luispadron avatar luispadron commented on June 12, 2024

I can give that a try and report back.

I did try to create a minimal server and client to share but that worked for both build systems (this was using a stripped down version of both the server and client).

The minimal server I built also worked with our large iOS client to establish a connection using both build systems, which I can only imagine means the issue is with the server and how it gets built/linked?

Is there anything I can enable to debug further? All I have to go off on is the error message I posted above.

The handshake failure comes right after calling resume on a URLSessionWebSocketTask on the iOS client.

from swift-nio.

luispadron avatar luispadron commented on June 12, 2024

@Lukasa thanks for your help here! I'm very much a newb here.

I haven't had a chance to get the exact web info yet but on the android client when it connects to the Bazel built server we do get some more info:

Throwable java.net.ProtocolException: 
Expected 'Sec-WebSocket-Accept' header value 'eabW+NOBcvdzRVggc2z4oTgL8Og=' but was 'CBn5S5K8ShGNaOtKxZc7/ldcyno='

from swift-nio.

luispadron avatar luispadron commented on June 12, 2024

One of our engineers also determined the culprit seems to be from the hash of SHA1.swift differing between the two build systems.

Using CryptoKit we get the same SHA but using SHA1 from swift-nio these values differ for the same input.

Xcode:

Screenshot 2023-11-28 at 10 01 14 AM

Bazel:

Screenshot 2023-11-28 at 10 01 18 AM

Do you know of any build time flags, language standards and such that would change this behavior?

from swift-nio.

luispadron avatar luispadron commented on June 12, 2024

I've confirmed the root cause is BYTE_ORDER is coming back as BIG_ENDIAN which is incorrect for macOS arm64. Seems like a similar issue to: #2584

from swift-nio.

luispadron avatar luispadron commented on June 12, 2024

This minimal repo demonstrates the issue: https://github.com/luispadron/bazel-big-endian-on-macos

from swift-nio.

Lukasa avatar Lukasa commented on June 12, 2024

Can you confirm that you're using version 2.62.0? That contains the fix from #2584.

from swift-nio.

luispadron avatar luispadron commented on June 12, 2024

Confirmed that 2.62.0 fixes this issue for Bazel build. Thanks so much for your responsiveness here @Lukasa

from swift-nio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.