无法在python中的TCPListner内部与RabbitMQ Broker创建超过255个MQTT连接

时间:2015-09-07 13:02:52

标签: python rabbitmq mqtt

通过python类HTML/JS的TCPListner,当连接到RabbitMQ代理时,我无法获得超过250-255的mqtt连接,以下是我的代码:

ThreadedTCPServer

因此,当连接到代理时,我为每个新的TCP请求创建了不同的连接,但它不会超过255.

对于python class service(SocketServer.BaseRequestHandler): def handle(self): def on_connect(client, userdata, flags, rc): client.subscribe("subscribe") def on_message(client, userdata, msg): print "Received on Topic : '"+str(msg.topic)+"' and Message is : "+str(msg.payload) strConnName="MQTT-Pub-Sub-"+str(self.client_address) mqttc = mqtt.Client(strConnName,True,threadcounter) mqttc.on_connect = on_connect mqttc.on_message = on_message mqttc.on_disconnect = on_disconnect mqttc.connect("BROKERIP", 1883, 1000) mqttc.loop_start() while True: data = self.request.recv(8192) if data: mqttc.publish("routing_key",str(data)) class ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): pass SocketServer.TCPServer.allow_reuse_address = True t = ThreadedTCPServer((socket.gethostname(),PORT), service) t.serve_forever() 类或任何缺少或需要配置的东西是否有任何限制。虽然我的机器ThreadedTCPServer

提前致谢。

0 个答案:

没有答案