SocketsBay.com documenation

Your free WebSockets server - We can provide you with a ready to use technical solution to your WebSockets needs.

Overview

SocketsBay.com is an open WebSocket server, anyone can create an account and generate an API key to start using the server. There is no additional plugin or library installation required in your app to use the SocketBay. server. The following URL is all you need:

Copy the WebSocket server URL below, replace CHANNEL_ID (it can be any positive integer) and API_KEY

Try it

You can use the Online Websocket Tester.

This tool can be used to test other websocket servers too.

Parameters

Channel Id

It should be a positive integer ( from 1 to 10.000.000 )

When a message is sent by a user, it is passed to only the members of the sender's channel.

For example: Let's say you are using two SocketsBay.com endpoints,

Suppose, there are 5 users connected to each channel. When a user from channel 10 sends a message, it is recieved by other 4 members of the channel 10 only.

Users connected to the 20 channel will not receive any message from the 10 channel

API Key

You can generate API Keys from your SocketsBay.com account for free. Just create another App in your account and you will automatically get a new API Key.

For example: Let's say you have a chat application. Each private conversation is on another channel. So you will have the following url's:

Code Samples

                            
    var wsUri = "wss://socketsbay.com/wss/v2/[ChannelId]/[ApiKey]/";
    var log;

    function init()
    {
      log = document.getElementById("log");
      testWebSocket();
    }

    function testWebSocket()
    {
      websocket = new WebSocket(wsUri);
      websocket.onopen    = function(evt) { onOpen(evt)    };
      websocket.onclose   = function(evt) { onClose(evt)   };
      websocket.onmessage = function(evt) { onMessage(evt) };
      websocket.onerror   = function(evt) { onError(evt)   };
    }

    function onOpen(evt)
    {
      writeLog("CONNECTED");
      sendMessage("Hello world");
    }

    function onClose(evt)
    {
      writeLog("Websocket DISCONNECTED");
    }

    function onMessage(evt)
    {
      writeLog('RESPONSE: ' + evt.data );
      websocket.close();
    }

    function onError(evt)
    {
      writeLog('ERROR: ' + evt.data);
    }

    function sendMessage(message)
    {
      writeLog("SENT: " + message);
      websocket.send(message);
    }

    function writeLog(message)
    {
      var pre = document.createElement("p");
      pre.innerHTML = message;
      log.appendChild(pre);
    }

    window.addEventListener("load", init, false);
                            
                        
                            
private void createWebSocketClient() {
    URI uri;
    try {
      // Connect to local host
      uri = new URI("wss://socketsbay.com/wss/v2/[ChannelId]/[ApiKey]/");
    }
    catch (URISyntaxException e) {
      e.printStackTrace();
      return;
    }
    webSocketClient = new WebSocketClient(uri) {
      @Override
      public void onOpen() {
        Log.i("WebSocket", "Session is starting");
        webSocketClient.send("Hello World!");
      }
      @Override
      public void onTextReceived(String s) {
        Log.i("WebSocket", "Message received");
        final String message = s;
        runOnUiThread(new Runnable() {
          @Override
          public void run() {
            try{
              TextView textView = findViewById(R.id.animalSound);
              textView.setText(message);
            } catch (Exception e){
                e.printStackTrace();
            }
          }
        });
      }
      @Override
      public void onBinaryReceived(byte[] data) {
      }
      @Override
      public void onPingReceived(byte[] data) {
      }
      @Override
      public void onPongReceived(byte[] data) {
      }
      @Override
      public void onException(Exception e) {
        System.out.println(e.getMessage());
      }
      @Override
      public void onCloseReceived() {
        Log.i("WebSocket", "Closed ");
        System.out.println("onCloseReceived");
      }
    };
    webSocketClient.setConnectTimeout(10000);
    webSocketClient.setReadTimeout(60000);
    webSocketClient.enableAutomaticReconnection(5000);
    webSocketClient.connect();
  }
                            
Read more here
                            
private fun createWebSocketClient() {
  val uri:URI
  try
  {
    // Connect to local host
    uri = URI("ws://10.0.2.2:8080/websocket")
  }
  catch (e:URISyntaxException) {
    e.printStackTrace()
    return
  }
  webSocketClient = object:WebSocketClient(uri) {
    fun onOpen() {
      Log.i("WebSocket", "Session is starting")
      webSocketClient.send("Hello World!")
    }
    fun onTextReceived(s:String) {
      Log.i("WebSocket", "Message received")
      val message = s
      runOnUiThread(object:Runnable {
        public override fun run() {
          try
          {
            val textView = findViewById(R.id.animalSound)
            textView.setText(message)
          }
          catch (e:Exception) {
            e.printStackTrace()
          }
        }
      })
    }
    fun onBinaryReceived(data:ByteArray) {}
    fun onPingReceived(data:ByteArray) {}
    fun onPongReceived(data:ByteArray) {}
    fun onException(e:Exception) {
      println(e.message)
    }
    fun onCloseReceived() {
      Log.i("WebSocket", "Closed ")
      println("onCloseReceived")
    }
  }
  webSocketClient.setConnectTimeout(10000)
  webSocketClient.setReadTimeout(60000)
  webSocketClient.enableAutomaticReconnection(5000)
  webSocketClient.connect()
}
                            
Read more here
                            
func echoTest(){
    var messageNum = 0
    let ws = WebSocket("wss://socketsbay.com/wss/v2/[ChannelId]/[ApiKey]/")
    let send : ()->() = {
        messageNum += 1
        let msg = "\(messageNum): \(NSDate().description)"
        print("send: \(msg)")
        ws.send(msg)
    }
    ws.event.open = {
        print("opened")
        send()
    }
    ws.event.close = { code, reason, clean in
        print("close")
    }
    ws.event.error = { error in
        print("error \(error)")
    }
    ws.event.message = { message in
        if let text = message as? String {
            print("recv: \(text)")
            if messageNum == 10 {
                ws.close()
            } else {
                send()
            }
        }
    }
}
                            
Read more here here

Rate Limit

Rate limit depends upon the plan you are on, see all of them here

Online tester

You can use our Tester

If you continue to browse, we’ll use cookies that make our site work, improve performance, and customise your experience. If you accept, we’ll will not use cookies for ads.