Skip to content
This repository has been archived by the owner on Feb 11, 2020. It is now read-only.

how mosca create a wss server,how to connect? #655

Open
warfrogsdf opened this issue Jul 3, 2017 · 9 comments
Open

how mosca create a wss server,how to connect? #655

warfrogsdf opened this issue Jul 3, 2017 · 9 comments

Comments

@warfrogsdf
Copy link

const moscaSetting = {
interfaces: [
{ type: "mqtt", port: 1883 },
{ type: "mqtts", port: 8883, credentials: { keyPath: SECURE_KEY, certPath: SECURE_CERT } },
{ type: "http", port: 3000, bundle: true },
{ type: "https", port: 3001, bundle: true, credentials: { keyPath: SECURE_KEY, certPath: SECURE_CERT } }
],
secure : {
keyPath: SECURE_KEY,
certPath: SECURE_CERT,
},
stats: false,
onQoS2publish: 'noack', // can set to 'disconnect', or to 'dropToQoS1' if using a client which will eat puback for QOS 2; e.g. mqtt.js

logger: { name: 'MoscaServer', level: 'debug' },

persistence: { factory: mosca.persistence.Redis, url: 'localhost:6379', ttl: { subscriptions: 1000 * 60 * 10, packets: 1000 * 60 * 10 } },

backend: pubsubSettings,

};

but var client = mqtt.connect('mqtts://:3001/');error:
mqtt.js:9 WebSocket connection to 'wss://
:3001/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED?why?

@mcollina
Copy link
Collaborator

mcollina commented Jul 3, 2017

Can you paste the client as well?

@warfrogsdf
Copy link
Author

<script src="./mqtt/mqtt.js"></script>

var client = mqtt.connect('mqtts://mydomain.com:3001/')

    client.on('connect', function () {
        client.subscribe('presence')
        client.publish('presence', 'Hello mqtt')
    })

    client.on('message', function (topic, message) {
        // message is Buffer
        console.log(message.toString())
        client.end()
    })

@warfrogsdf
Copy link
Author

use
var client = mqtt.connect('mqtt://mydomain.com:3000/')

client.on('connect', function () {
    client.subscribe('presence')
    client.publish('presence', 'Hello mqtt')
})

client.on('message', function (topic, message) {
    // message is Buffer
    console.log(message.toString())
    client.end()
})

is ok。

the other: how of mosca perfermance .my company maybe use in production

@mcollina
Copy link
Collaborator

mcollina commented Jul 3, 2017

Are you deploying through Nginx or Haproxy? Also, check firewall of your domain.

Performance depends on how many clients do you plan to connect/etc.

@warfrogsdf
Copy link
Author

so,my mosca server config is right?
but my linux server config or mqtt client config error?

@mcollina
Copy link
Collaborator

mcollina commented Jul 3, 2017

If you curl -v https://mydomain.com:3001 what is the output?

@warfrogsdf
Copy link
Author

maybe my https certificate no right,txs。other,this project has slack?

@warfrogsdf
Copy link
Author

txs

@mcollina
Copy link
Collaborator

mcollina commented Jul 3, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants