Testing a Socket.IO while development

We are using Socket.IO on almost all our real-time applications. While developing the backend for socket io, we always develop a web version for testing and establishing the connections, once done passed the names of the events and data format to the frontend team. Since we write the code every moment we developed a socket, we decide to develop a tool that can connect to any backend at any time. I am here to share the tool with you.

SocketIO Client Online Image - no details


Socket Testing

SocketIO Testing is a tool developed by Blogger Nepal. :P. You can find the tool on https://socketio.bloggernepal.com/. Let's talk about the fields on the tool.

Url: the URL of the server, including the protocol, eg "https://bunnyjump.bloggernepal.com/"

nameSpace: the namespace to connect if there is.

Query: key-value pair for each query, eg key: token, value: "the token here" Only two for now.

Connect:  the connect button to establish the socket connection.

Now the socket connection is established, What socket without listening to some events.

Events to Listen: list of comma-separated events to listen to. eg echo, newPost

We can send socket event as well using this tool. 

Event name: Name of the event you want to emit.

Event Data: the data you want to share, You need to provide the data in JSON format, Here we are using JSON.parse(data) so it should be strict JSON. If you have an idea on improving this, let us know.

Emit: the Emit Button clicked to emit the event.

You need to listen to another event? you can do so with "A Event to Listen". We can still use the "Events to Listen" wala array, since we have already developed it, let it be there. :) 

The homepage one is using socket.io-client 2.3.0, you can find other clients as well on the Other Versions.

Find the guide on this video:-

Log: In the log section, you can view the logs, with the time. New events will be added on top of the list, so you need not to scroll often. If the Server emitted an event and we have listened to it, it will be logged there. The event name and data received.

Conclusion

Here we discussed a socketIO testing tool, we can use it to test our socketio service, while developing. It is still in the development phase, We are planning to make it available even on offline through PWA. If you have any suggestions, please let us know through the comment section.

Posted by Sagar Devkota

0 Comments