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:
host
string
Default:"localhost"
remote host addressport
integer
Default:61613
remote port addresstimeout
integer
Default:3000
timeout for the transport connect operationconnectHeaders
object
Default:{}
headers to be sent in the connect framepath
string
use unix domain socket and use path as the destination addressssl
boolean
Default:false
use secure connectionconnect
function
override the transport factory constructor used
Options available when ssl is set to true:
pfx
string or Buffer
private key, certificate and CA certs of client in PFX or PKC12 format.key
string or Buffer
private key of the client in PEM formatpassphrase
string
passhrase for the private keycert
string or Buffer
containing the certificate file of the client in PEM formatca
array 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-version
negotiate protocol version. By default stompit accepts "1.0,1.1,1.2"heart-beat
enable heart-beating. Format of header value:x,y
where x and y are the number of milliseconds between heart-beats sent and received respectively.host
virtual host name of serverlogin
client usernamepasscode
client 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) {
});