socketio / socket.io

Realtime application framework (Node.JS server)
https://socket.io
MIT License
61.2k stars 10.11k forks source link

Including Protocol Parameter in Socket Connection Creation in iOS #4923

Open Abhishekchugh01941 opened 10 months ago

Abhishekchugh01941 commented 10 months ago

Problem: I am currently facing difficulties in establishing a socket connection from my iOS app due to the absence of a parameter to specify the sub-protocol during the socket creation process. This is particularly problematic as I need to connect using the 'graphql-ws' sub-protocol, and the current implementation lacks support for this.

The addition of a parameter in the socket creation process that allows users to specify the desired sub-protocol, particularly for cases like mine where 'graphql-ws' is required. This can be added while creating socket Manager object where socket url and configuration are declared.

Our web team has implemented socket connections in the Angular framework, and they are utilizing the 'graphql-ws' sub-protocol. new WebSocket(url, ['graphql-ws']);

Refer to the following link: https://stackoverflow.com/questions/74276986/websocket-connection-to-appsync-errorcode-400-noprotocolerror

darrachequesne commented 9 months ago

Hi! You can provide a protocols option, which will be forwarded to the WebSocket constructor.

const socket = io({
  transports: ["websocket"],
  protocols: ["graphql-ws"]
});

Reference: https://socket.io/docs/v4/client-options/#protocols