socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

Including Protocol Parameter in Socket Connection Creation in iOS

Open Abhishekchugh01941 opened this issue 1 year ago • 1 comments

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

Abhishekchugh01941 avatar Jan 17 '24 11:01 Abhishekchugh01941

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

darrachequesne avatar Feb 01 '24 07:02 darrachequesne