你可以使用sip.js通过wss连接到FreeSWITCH。

huangapple go评论88阅读模式
英文:

How can I use sip.js connect freeswitch with wss

问题

I am trying to register with the server using sipjs. It can work with ws, but when I use wss, some errors occur. I have used a self-signed certificate wss.pem to replace the old one.

freeswitch error:

tport.c:2777 tport_wakeup_pri() tport_wakeup_pri(0x7fe5c800be90): events IN
tport.c:867 tport_alloc_secondary() tport_alloc_secondary(0x7fe5c800be90): new secondary tport 0x7fe5c8018990
tport.c:2103 tport_close() tport_close(0x7fe5c8018990): (null)/(null):(null)
tport_type_ws.c:641 tport_ws_next_timer() tport_ws_next_timer(0x7fe5c8018990): Error establishing SSL to (null)/(null):(null)
tport.c:2278 tport_set_secondary_timer() tport(0x7fe5c8018990): set timer at 0 ms because zap
tport.c:2103 tport_close() tport_close(0x7fe5c8018990): (null)/(null):(null)
tport_type_ws.c:535 tport_ws_deinit_secondary() 0x7fe5c8018990 destroy wss transport 0x7fe5c8018b80.

sip.js:

const transportOptions = {
    server: "wss://10.16.127.26:7443" // fs
};

const fake_uri = 'sip:' + extName + '@10.16.127.26';
const uri = UserAgent.makeURI(fake_uri);
const targeturi = UserAgent.makeURI(target);

if (!uri) {
    throw new Error("Failed to create URi");
}

const userAgentOptions = {
    authorizationPassword: '1234',
    authorizationUsername: '1001',
    transportOptions,
    uri,
};

const userAgent = new UserAgent(userAgentOptions);

connect.addEventListener('click', e => {
    const registerer = new Registerer(userAgent);
    userAgent.start().then(() => {
        registerer.register()
        console.log('11');
    });
})
英文:

I am trying to register with the server using sipjs.It can works with ws,but when i use wss,some errors occured.I have used a self-signed certificate wss.pem to instead the old one

freeswitch error

tport.c:2777 tport_wakeup_pri() tport_wakeup_pri(0x7fe5c800be90): events IN
tport.c:867 tport_alloc_secondary() tport_alloc_secondary(0x7fe5c800be90): new secondary tport 0x7fe5c8018990
tport.c:2103 tport_close() tport_close(0x7fe5c8018990): (null)/(null):(null)
tport_type_ws.c:641 tport_ws_next_timer() tport_ws_next_timer(0x7fe5c8018990): Error establishing SSL to (null)/(null):(null)
tport.c:2278 tport_set_secondary_timer() tport(0x7fe5c8018990): set timer at 0 ms because zap
tport.c:2103 tport_close() tport_close(0x7fe5c8018990): (null)/(null):(null)
tport_type_ws.c:535 tport_ws_deinit_secondary() 0x7fe5c8018990 destroy wss transport 0x7fe5c8018b80.

sip.js

const transportOptions = {
        server: "wss://10.16.127.26:7443"//fs
      }; 
      //ua
    // const userAgent = new UserAgent({transportOptions});
    // userAgent.start();
    const fake_uri='sip:'+extName+'@10.16.127.26'
    const uri = UserAgent.makeURI(fake_uri);
    const targeturi=UserAgent.makeURI(target);
    if (!uri) {
        throw new Error("Failed to create URi");
      }
        const userAgentOptions = {
        authorizationPassword: '1234',
        authorizationUsername: '1001',
        transportOptions,
        // hackWssInTransport: true,
        uri,
      };
    const userAgent = new UserAgent(userAgentOptions);
    connect.addEventListener('click',e=>{
            // console.log('ok');
        const registerer = new Registerer(userAgent);
        userAgent.start().then(() => {
          registerer.register()
          console.log('11');
        });
        // console.log( registerer.register());
        })

答案1

得分: 2

你提到了使用自签名证书,可能是因为你的浏览器未完全建立TLS连接,当它检测到不信任的证书时断开连接。通常,您可以通过颁发有效的证书或在浏览器中访问freeswitch实例并通过证书验证失败来解决此问题。

对于你来说,这意味着在浏览器中访问https://10.16.127.26:7443,并点击通过证书警告。完成后返回到您的sipjs页面并重试。

这只是一个猜测,可能还有其他问题。浏览器的控制台或freeswitch日志中可能有更多信息。

英文:

You mention having a self signed certificate, is it possible your browser isn't fully establishing the TLS connection and disconnecting when it sees the untrusted cert? You can typically get around this by issuing a valid cert or visiting the freeswitch instance in a browser as a page and clicking through the certificate validation failure.

For you, that means going to https://10.16.127.26:7443 in a browser and clicking through the cert warning. When you've done that go back to your sipjs page and try again.

this is just a guess, you might have other issues. There might be more information in the browser's console or elsewhere in the freeswitch logs.

huangapple
  • 本文由 发表于 2023年5月13日 19:12:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76242419.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定