Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question]how can i use one server to listen muti ports? #17

Open
Drswith opened this issue Sep 1, 2021 · 1 comment
Open

[question]how can i use one server to listen muti ports? #17

Drswith opened this issue Sep 1, 2021 · 1 comment
Labels
question Further information is requested

Comments

@Drswith
Copy link

Drswith commented Sep 1, 2021

like emqx,i neet to listen 4 ports use one server(tcp :1883,tls:8883,ws:8083,wss:8084)

I have checked the README but all examples are use one port
how can i do?
thanks

@Drswith Drswith added the question Further information is requested label Sep 1, 2021
@pierluigizagaria
Copy link

pierluigizagaria commented Nov 18, 2021

You can do something like this

const broker = aedes();
const mqtt = aedesFactory.createServer(broker);
const mqttWs = aedesFactory.createServer(broker, { ws: true });

mqtt.listen(MQTT_BROKER.PORT, MQTT_BROKER.HOST, () => {
  console.log(`MQTT broker over tcp listening on port ${MQTT_BROKER.PORT}`);
})

mqttWs.listen(MQTT_BROKER.WS_PORT, MQTT_BROKER.HOST, () => {
  console.log(`MQTT broker over ws listening on port ${MQTT_BROKER.WS_PORT}`);
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants