socket.io
socket.io copied to clipboard
Including Protocol Parameter in Socket Connection Creation in iOS
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
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