onsip / SIP.js

A simple, intuitive, and powerful JavaScript signaling library
https://sipjs.com
MIT License
1.88k stars 700 forks source link

sip.transport | error connecting to WebSocket wss://xxx.yyy.zzz.vvv: TypeError: t is not a constructor #542

Closed chefkoch009 closed 6 years ago

chefkoch009 commented 6 years ago

I get this message if I start:

sip.transport | error connecting to WebSocket wss://xxx.yyy.zzz.vvv: TypeError: t is not a constructor

and later:

TypeError: Cannot set property 'binaryType' of null at i.connect (\node_modules\sip.js\dist\sip.min.js:38:189496) at new i (\node_modules\sip.js\dist\sip.min.js:38:187581) at o.start (\node_modules\sip.js\dist\sip.min.js:38:114349) at new o (\iobroker\node_modules\sip.js\dist\sip.min.js:38:111720) at Object. (\node_modules\iobroker.sip\main.js:17:13) at Module._compile (module.js:643:30) at Object.Module._extensions..js (module.js:654:10) at Module.load (module.js:556:32) at tryModuleLoad (module.js:499:12) at Function.Module._load (module.js:491:3)

this is my last program snippet:

const` SIP = require('sip.js'); const bob = new SIP.UA({ uri : 'user@ip.of.my.sipserver', wsServers : 'wss://ip.of.my.sipserver', register : true }); bob.start();

I tried some different configurations, but no one solved the problem. The installation of sip.js was via npm.

egreenmachine commented 6 years ago

Are you running this in a web browser?

chefkoch009 commented 6 years ago

No, in my dev-enviroment.

egreenmachine commented 6 years ago

Do you have websocket support? It appears that you are failing to connect to the websocket. You should see an error message along the lines of error connecting to WebSocket

chefkoch009 commented 6 years ago

Thanks for your fast response. Is it possible to connect to the SIP server without webSocket? Btw I'm able to connect to the SIP server with the SIP client "microSIP".

egreenmachine commented 6 years ago

You need to define your own Transport. It has been done in the past, but it is currently not a straight forward endeavor. I am actively working on cleaning up this piece of the code and making it easier to define your own. It will not be in the next release of SIP.js, but it should be the release after that.

chefkoch009 commented 6 years ago

Thanks for the information. For now I use askozia as SIP2WebRTC. But it makes all the Things much complex as it should. For example connecting to a door communication system. Or do you know an other way?

JimGreenberg commented 6 years ago

An update on this: the 0.11.0 release represents a huge refactor for the transport code- with the purpose of making this type of thing a lot easier. The UA now has a configuration parameter transportConstructor where you can give it a user-defined Transport (as @egreenmachine said). This will allow you write your own Transport around the connection type of your choice. There isn't a formal guide yet, but the documentation has a writeup on both the Transport parent class, as well as the default websocket transport. This isn't going to be totally simple, but we tried to make it as straightforward as possible- as always, if you need help we have a mailing list that gets checked frequently.

sudoGenie commented 1 year ago

An update on this: the 0.11.0 release represents a huge refactor for the transport code- with the purpose of making this type of thing a lot easier. The UA now has a configuration parameter transportConstructor where you can give it a user-defined Transport (as @egreenmachine said). This will allow you write your own Transport around the connection type of your choice. There isn't a formal guide yet, but the documentation has a writeup on both the Transport parent class, as well as the default websocket transport. This isn't going to be totally simple, but we tried to make it as straightforward as possible- as always, if you need help we have a mailing list that gets checked frequently.

@JimGreenberg Is there a Update to where we can specify not to use WSS and strictly use our own Transport UDP (dgram) or TCP (net)