Max connections

Asked by Cyril Cauchois

Hello,

   Is it possible to set a "max_connections" parameter ?
   I made some tests, and it looks like mosquitto server cannot handle more than 60 simultaneous connexions.
   Is there a way to change that ?

Regards.

Question information

Language:
English Edit question
Status:
Answered
For:
mosquitto Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Roger Light (roger.light) said :
#1

Hi Cyril, thanks for getting in touch.

There is no max_connections parameter at the moment. It'll definitely be there in the future - I aim to replicate all of the options that are available in the IBM broker, rsmb.

Can you share any of the details of the kind of connections you're attempting? The kind of things I mean are the number of subscriptions per client, whether all clients are subscribing on the same topics, the number of messages per second, the size of message and anything else you think is relevant. I'm definitely interested in pushing that number up!

Could you also give me a better idea of what you mean by "handle"? Does client number 61 not get a connection or does performance simply degrade?

Revision history for this message
Cyril Cauchois (cyril-cc) said :
#2

Hello,

  My tests are really simple.
  I launch the mosquitto server (win32 binaries out of the box) on my PC.
  And then I start a small java application built with the wmqtt library (provided by IBM).
  This application does a simple loop like that :

                   for (int i=0; i < maxClient; i++) {

   System.out.println("connecting client #"+i);
   try {
    clients[currentClient] = connectToBroker(hostname, port, prefixClient+currentClient);
    clients[currentClient].subscribe(topics, qos);
    Thread.sleep(sleepTime);
    currentClient++;
   } catch (MqttException e) {
    e.printStackTrace();
    break;
   } catch (InterruptedException e) {
    e.printStackTrace();
   }

  }

  So ; just a connection and a suscribtion (only 1 topic). The connect method is like that :

 public static IMqttClient connectToBroker(String hostname, int port, String clientId) throws MqttException {

  final String mqttConnSpec = "tcp://" + hostname + "@" + port;
  IMqttClient mqttClient = MqttClient.createMqttClient(mqttConnSpec, null);
  mqttClient.connect(clientId, true, (short)60);

  return mqttClient;

 }

 The loop stops at connection #60 ; the server never respond to the connection.
  I made the same test with rsmb under Linux (fedora), and the loop stops at connection #1020 (that might be a Linux issue)

Regards

Revision history for this message
Roger Light (roger.light) said :
#3

That's very useful. It looks as though the default under cygwin (the Windows compiled version) the maximum number of connections possible is 64.

Under Linux, a similar limit gives rise to the 1020 connections. It's easy to change the limit on Linux by using e.g. "ulimit -n 2048" to set the maximum number of open files/sockets to 2048.

For the Windows version, the limit is compiled in so I'll have to recompile it with a larger value. I need to update the Windows binaries anyway!

Revision history for this message
Roger Light (roger.light) said :
#4

Sorry, that's not true about the limit on Linux because above the ulimit setting there is another 1024 limit.

Revision history for this message
Cyril Cauchois (cyril-cc) said :
#5

Thanks for your quick answers !
It would be nice to have the max_connections parameter.

I heard that I have to rebuild the kernel to remove the 1024 sockets limitation. I'll give you some news.

Revision history for this message
Roger Light (roger.light) said :
#6

That's true, but a better solution is for me to change from using select() to poll(), which has no limit on connections. I'm working on that now.

I'll also move max_connections higher up the list of things to implement.

Can you help with this problem?

Provide an answer of your own, or ask Cyril Cauchois for more information if necessary.

To post a message you must log in.