drachtio / drachtio-srf

drachtio signaling resource framework
https://drachtio.org
MIT License
171 stars 60 forks source link

ws connect to asterisk #184

Open DavidGOrtega opened 1 month ago

DavidGOrtega commented 1 month ago

Hi!

I have looked thought the issues, docs... on how to connect via ws. The only reference that I have found is specifying the transport.

I have tried to connect to my asterisk instance with a sipUri like sip:trunk.mydomain.com:8088/ws;transport=ws of course I have tried the canonical that I use with our softphone 008 ws:trunk.mydomain.com:8088/ws but no luck yet.

Im trying with

srf.request(sipUri, registerMessage, (err, req) => {

ws:trunk.mydomain.com:8088/ws gives the error

Error: invalid request-uri: REGISTER ws:trunk.mydomain.com:8088/ws;transport=ws SIP/2.0
    at DrachtioAgent.<anonymous> (/Users/davidgortega/Documents/projects/kunzite/008Q/node_modules/drachtio-srf/lib/drachtio-agent.js:315:21)
    at DrachtioAgent._onMsg (/Users/davidgortega/Documents/projects/kunzite/008Q/node_modules/drachtio-srf/lib/drachtio-agent.js:749:11)
    at WireProtocol.emit (node:events:517:28)
    at WireProtocol._onData (/Users/davidgortega/Documents/projects/kunzite/008Q/node_modules/drachtio-srf/lib/wire-protocol.js:306:14)
    at Socket.emit (node:events:517:28)
    at addChunk (node:internal/streams/readable:368:12)
    at readableAddChunk (node:internal/streams/readable:341:9)
    at Readable.push (node:internal/streams/readable:278:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)

with sip:trunk.mydomain.com:8088/ws;transport=ws drachtio-server crashes

drachtio-server  | 2024-10-17 13:54:28.202854 SipDialogController::doSendRequestOutsideDialog - using client-specified call-id: 678896
drachtio-server  | 2024-10-17 13:54:28.202905 isLocalSipUri: checking to see if this is one of mine: sip:trunk.mydomain.com:8088ws;transport=ws
drachtio-server  | drachtio: sip_basic.c:240: sip_request_create: Assertion `b == end' failed.

Any help would be appreciated. Thanks

danvirsen commented 3 weeks ago

The SIP URIs you tried aren't valid. Have you tried with sip:trunk.mydomain.com:8088;transport=ws?

DavidGOrtega commented 2 weeks ago

Hi @danvirsen thanks for the reply.

The SIP URIs you tried aren't valid. Have you tried with sip:trunk.mydomain.com:8088;transport=ws?

No one should be listening at sip:trunk.mydomain.com:8088. Asterisk is launching the socket at sip:trunk.mydomain.com:8088/ws