Function: stompit.connect
Creates a stompit.Client object and connects to a server.
The connectionListener callback (an observer of the client object's connect
event) is called when the client is connected and is ready to send and subscribe.
The return value is a new client object.
Supported call patterns:
stompit.connect(options, [connectionListener])stompit.connect(port, [host], [connectionListener])stompit.connect(path, [connectionListener])
Options:
hoststringDefault:"localhost"remote host addressportintegerDefault:61613remote port addresstimeoutintegerDefault:3000timeout for the transport connect operationconnectHeadersobjectDefault:{}headers to be sent in the connect framepathstringuse unix domain socket and use path as the destination addresssslbooleanDefault:falseuse secure connectionconnectfunctionoverride the transport factory constructor used
Options available when ssl is set to true:
pfxstring or Bufferprivate key, certificate and CA certs of client in PFX or PKC12 format.keystring or Bufferprivate key of the client in PEM formatpassphrasestringpasshrase for the private keycertstring or Buffercontaining the certificate file of the client in PEM formatcaarray of strings of Buffers of trusted certificates in PEM format
Under the hood net.connect and tls.connect functions are used so any options
they have available that are undocumented here are also applicable to
stompit.connect function.
Standard headers
Set the connectHeaders option with an object containing the headers to be
included in the connect frame. Below are the list of standard headers supported
by STOMP servers.
accept-versionnegotiate protocol version. By default stompit accepts "1.0,1.1,1.2"heart-beatenable heart-beating. Format of header value:x,ywhere x and y are the number of milliseconds between heart-beats sent and received respectively.hostvirtual host name of serverloginclient usernamepasscodeclient password
Example
var connectOptions = {
'host': 'localhost',
'port': 61613,
'connectHeaders':{
'heart-beat': '1000,2000',
'host': 'localhost',
'login': 'username',
'passcode': 'password'
}
};
stompit.connect(connectOptions, function(error, client) {
});