onsip / SIP.js

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

Sip 2 sip calling with sip.js Invitation not recived #1079

Open thanossOp opened 2 months ago

thanossOp commented 2 months ago

### Sender.html

`<!DOCTYPE html>

SIP Calling

SIP Calling Demo

` websocket.js `import { WebSocket, WebSocketServer } from "ws"; const wss = new WebSocketServer({ port: 8080 }); wss.on('listening', () => { console.log('WebSocket server running on ws://localhost:8080'); }); wss.on('connection', (ws) => { console.log('Client connected'); ws.on('message', (message) => { try { const data = JSON.parse(message); console.log('Received message:', data); switch (data.event) { case 'call': broadcastEventExcept(ws, 'incoming_call'); break; case 'accepted': broadcastEventExcept(ws, 'acceptedCall'); break; case 'rejected': broadcastEventExcept(ws, 'rejectedCall'); break; case 'endCall': broadcastEventExcept(ws, 'endCall'); break; default: console.warn('Unknown event:', data.event); break; } } catch (error) { console.error('Error parsing message:', error); } }); ws.on('close', () => { console.log('Client disconnected'); }); }); function broadcastEventExcept(excludedClient, event) { wss.clients.forEach((client) => { if (client !== excludedClient && client.readyState === WebSocket.OPEN) { client.send(JSON.stringify({ event: event })); } }); > }` reciver.html ` SIP Calling Receiver

SIP Calling Receiver

` **### reciver console** WebSocket connected reciver.html:27 Received message: {event: 'incoming_call'} sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | Configuration: sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · allowLegacyNotifications: false sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · authorizationHa1: "" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · authorizationPassword: NOT SHOWN sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · authorizationUsername: "" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · autoStart: false sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · autoStop: true sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · delegate: {} sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · contactName: "" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · contactParams: {"transport":"ws"} sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · displayName: "" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · forceRport: false sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · hackAllowUnregisteredOptionTags: false sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · hackIpInContact: false sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · hackViaTcp: false sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · logBuiltinEnabled: true sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · logConfiguration: true sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · logConnector: undefined sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · logLevel: "log" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · noAnswerTimeout: 60 sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · preloadedRouteSet: [] sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · reconnectionAttempts: 0 sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · reconnectionDelay: 4 sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · sendInitialProvisionalResponse: true sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · sessionDescriptionHandlerFactory: (t,s)=>{void 0===e&&(e=it());const i={iceGatheringTimeout:void 0!==(null==s?void 0:s.iceGatheringTimeout)?null==s?void 0:s.iceGatheringTimeout:5e3,peerConnectionConfiguration:Object.assign(Object.assign({},{bundlePolicy:"balanced",certificates:void 0,iceCandidatePoolSize:0,iceServers:[{urls:"stun:stun.l.google.com:19302"}],iceTransportPolicy:"all",peerIdentity:void 0,rtcpMuxPolicy:"require"}),null==s?void 0:s.peerConnectionConfiguration)},r=t.userAgent.getLogger("sip.SessionDescriptionHandler");return new nt(r,e,i)} sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · sessionDescriptionHandlerFactoryOptions: {} sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · sipExtension100rel: "Unsupported" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · sipExtensionReplaces: "Unsupported" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · sipExtensionExtraSupported: [] sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · sipjsId: "6doim" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · transportConstructor: at sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · transportOptions: {"wsServers":"ws://localhost:8080"} sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · uri: sip:UserB@your.sip.server.com sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · userAgentString: "SIP.js/0.20.0" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · viaHost: "nek2our57rpd.invalid" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · authorizationUser: "UserB" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · password: "password" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Transport | The transport option "wsServers" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly. print @ sip.min.js:2 genericLog @ sip.min.js:2 genericLog @ sip.min.js:2 warn @ sip.min.js:2 at @ sip.min.js:2 ct @ sip.min.js:2 answerCall @ reciver.html:48 onclick @ reciver.html:12 sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | Configuration: sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | · expires: 600 sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | · extraContactHeaderParams: [] sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | · extraHeaders: [] sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | · logConfiguration: true sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | · instanceId: "" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | · params: {} sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | · regId: 0 sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | · registrar: sip:your.sip.server.com sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | · refreshFrequency: 99 sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | Starting sip:UserB@your.sip.server.com sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | Transitioned from Stopped to Started sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Transport | Connecting ws://localhost:8080 sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Transport | Transitioned from Disconnected to Connecting sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Transport | WebSocket opened ws://localhost:8080 sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Transport | Transitioned from Connecting to Connected reciver.html:54 UserAgent started successfully sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | Waiting toggled to true sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Transport | Sending WebSocket message: REGISTER sip:your.sip.server.com SIP/2.0 Via: SIP/2.0/WS nek2our57rpd.invalid;branch=z9hG4bK99063 To: From: ;tag=idsudie5cr CSeq: 2 REGISTER Call-ID: 6doimviiaj9nlv5aihhu Max-Forwards: 70 Contact: ;expires=600 Allow: ACK,CANCEL,INVITE,MESSAGE,BYE,OPTIONS,INFO,NOTIFY,REFER Supported: outbound, path, gruu User-Agent: SIP.js/0.20.0 Content-Length: 0 WebSocket connected reciver.html:27 Received message: {event: 'incoming_call'} sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | Configuration: sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · allowLegacyNotifications: false sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · authorizationHa1: "" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · authorizationPassword: NOT SHOWN sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · authorizationUsername: "" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · autoStart: false sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · autoStop: true sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · delegate: {} sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · contactName: "" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · contactParams: {"transport":"ws"} sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · displayName: "" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · forceRport: false sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · hackAllowUnregisteredOptionTags: false sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · hackIpInContact: false sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · hackViaTcp: false sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · logBuiltinEnabled: true sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · logConfiguration: true sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · logConnector: undefined sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · logLevel: "log" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · noAnswerTimeout: 60 sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · preloadedRouteSet: [] sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · reconnectionAttempts: 0 sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · reconnectionDelay: 4 sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · sendInitialProvisionalResponse: true sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · sessionDescriptionHandlerFactory: (t,s)=>{void 0===e&&(e=it());const i={iceGatheringTimeout:void 0!==(null==s?void 0:s.iceGatheringTimeout)?null==s?void 0:s.iceGatheringTimeout:5e3,peerConnectionConfiguration:Object.assign(Object.assign({},{bundlePolicy:"balanced",certificates:void 0,iceCandidatePoolSize:0,iceServers:[{urls:"stun:stun.l.google.com:19302"}],iceTransportPolicy:"all",peerIdentity:void 0,rtcpMuxPolicy:"require"}),null==s?void 0:s.peerConnectionConfiguration)},r=t.userAgent.getLogger("sip.SessionDescriptionHandler");return new nt(r,e,i)} sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · sessionDescriptionHandlerFactoryOptions: {} sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · sipExtension100rel: "Unsupported" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · sipExtensionReplaces: "Unsupported" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · sipExtensionExtraSupported: [] sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · sipjsId: "6doim" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · transportConstructor: at sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · transportOptions: {"wsServers":"ws://localhost:8080"} sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · uri: sip:UserB@your.sip.server.com sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · userAgentString: "SIP.js/0.20.0" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · viaHost: "nek2our57rpd.invalid" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · authorizationUser: "UserB" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | · password: "password" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Transport | The transport option "wsServers" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly. print @ sip.min.js:2 genericLog @ sip.min.js:2 genericLog @ sip.min.js:2 warn @ sip.min.js:2 at @ sip.min.js:2 ct @ sip.min.js:2 answerCall @ reciver.html:48 onclick @ reciver.html:12 sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | Configuration: sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | · expires: 600 sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | · extraContactHeaderParams: [] sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | · extraHeaders: [] sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | · logConfiguration: true sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | · instanceId: "" sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | · params: {} sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | · regId: 0 sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | · registrar: sip:your.sip.server.com sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | · refreshFrequency: 99 sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | Starting sip:UserB@your.sip.server.com sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.UserAgent | Transitioned from Stopped to Started sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Transport | Connecting ws://localhost:8080 sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Transport | Transitioned from Disconnected to Connecting sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Transport | WebSocket opened ws://localhost:8080 sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Transport | Transitioned from Connecting to Connected reciver.html:54 UserAgent started successfully sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Registerer | Waiting toggled to true sip.min.js:2 Thu May 09 2024 12:18:10 GMT+0530 (India Standard Time) | sip.Transport | Sending WebSocket message: REGISTER sip:your.sip.server.com SIP/2.0 Via: SIP/2.0/WS nek2our57rpd.invalid;branch=z9hG4bK99063 To: From: ;tag=idsudie5cr CSeq: 2 REGISTER Call-ID: 6doimviiaj9nlv5aihhu Max-Forwards: 70 Contact: ;expires=600 Allow: ACK,CANCEL,INVITE,MESSAGE,BYE,OPTIONS,INFO,NOTIFY,REFER Supported: outbound, path, gruu User-Agent: SIP.js/0.20.0 Content-Length: 0 when i send invitation to reciver its not reciving any invitation like in onInvite function i add some console but its not console in reciver side also i dont access my mic as its not going to onInvite function
thanossOp commented 2 months ago

The issue is solved i need to send whole sip message to reciver so it solved but amy one have ay idea abut after establish connection how can we run python script like after establish connection if i have speak function and in tha function i speak what is your name then reciver side speak that text