当前位置: 首页 > news >正文

Nginx wss to ws 折腾记

jssip 或 sipml5 <----wss--->nginx<---ws---->fs(5066)

fs_cli -x 'sofia loglevel all 9'

日志如下:

REGISTER sip:192.168.43.135 SIP/2.0
Via: SIP/2.0/WSS df7jal23ls0d.invalid;branch=z9hG4bKurFnCK9qJuXQlSrbszSL1S6wbCokKlLr;rport
From: <sip:1005@192.168.43.135>;tag=MMulT85Sh1aJFiE1tkZq
To: <sip:1005@192.168.43.135>
Contact: <sips:1005@df7jal23ls0d.invalid;rtcweb-breaker=no;transport=wss>;expires=200;click2call=no;+g.oma.sip-im;+audio;language="en,fr"
Call-ID: 0e23e99e-8037-f1f7-8b91-f47ed433c65c
CSeq: 50125 REGISTER
Content-Length: 0
Max-Forwards: 70
User-Agent: IM-client/OMA1.0 sipML5-v1.2016.03.04
Organization: Doubango Telecom
Supported: path

tport.c:3054 tport_deliver() tport_deliver(0x7f63cc073d60): msg 0x7f63cc0a40a0 (565 bytes) from ws/192.168.43.135:38184/sip next=(nil)
nta.c:2957 agent_recv_request() nta: received REGISTER sip:192.168.43.135 SIP/2.0 (CSeq 50125) (load: 0 rps)
nta.c:3225 agent_check_request_via() nta: Via check: invalid transport "SIP/2.0/WSS" from 192.168.43.135:38184
nta.c:3070 agent_recv_request() nta: REGISTER (50125) has invalid Via
tport.c:2315 tport_set_secondary_timer() tport(0x7f63cc073d60): reset timer
tport.c:2315 tport_set_secondary_timer() tport(0x7f63cc073d60): reset timer

5066 绑定的是 ws,但是收到的 via 是 wss, 于是报错,不回 sip 消息(正常应该是 401)

找到 nta.c,做下面的修改:

重新编译后再测试,可以注册,可以呼叫

查了下,有个链接可以参考

https://lists.freeswitch.org/pipermail/freeswitch-users/2015-February/110971.html

可能不容易访问,这里贴下:

Hello,we have placed Freeswitch behind a Apache ws tunnel proxy. Now, Freeswitch give me an error message because the sip_via is not correct.nta.c:3146 agent_check_request_via() nta: Via check: invalid transport
"SIP/2.0/WSS" from 127.0.0.1:39964
nta.c:2990 agent_recv_request() nta: REGISTER (1) has invalid ViaHow do I modify the sip via entry that Freeswitch is expecting? Where to set the
sip_via_address/protocol/port variables?Thanks

几小时候发帖写道:

Hello again,the problem lies in the nta.c function agent_check_request_via.My apache proxy translation is from wss to ws (which may sense if on lo), but
agent_check_request_via is still expecting WSS.As a workaround, I am transmitting wss even locally. With best regards

也就是说放弃了 Apache 转发的方案,jssip 直接连 mod_sofia 的 wss 端口。

附测试用的 nginx 配置文件:

## nginx ip: 192.168.43.135
## fs ip: 192.168.43.203## 没有域名
## nginx 自签名证书
## wss 转到 fs 的 5066 ws 端口upstream freeswitch_sofia {# freeswitch mod_sofia wsserver 192.168.43.203:5066;
}upstream freeswitch_verto {server 192.168.43.203:8081;
}server {listen 443 ssl;ssl_certificate /root/cert.pem;ssl_certificate_key /root/privkey.pem;ssl_prefer_server_ciphers  on;ssl_session_cache shared:SSL:1m;ssl_session_timeout 5m;client_max_body_size 100M;server_name 192.168.43.135:443;location / {root /var/www/;index index.html;gzip on;gzip_min_length 1k;gzip_buffers 4 16k;gzip_comp_level 2;gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;gzip_vary off;gzip_disable "MSIE [1-6]\.";}location /ws {proxy_connect_timeout 30m;proxy_send_timeout 1d;proxy_read_timeout 1d;proxy_pass http://freeswitch_sofia;proxy_redirect off;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";}location /api/ {add_header Access-Control-Allow-Origin *;add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';if ($request_method = 'OPTIONS') {return 204;}proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;proxy_set_header Host $http_host;proxy_set_header X-NginX-Proxy true;proxy_pass http://freeswitch_verto;proxy_redirect off;proxy_http_version 1.1;}
}server {listen 80;server_name 192.168.43.135;return 301 https://192.168.43.135:443$request_uri;
}

FreeSWITCH 版本:1.10.9

Nginx 版本:1.18.0-6.1

http://www.lryc.cn/news/349907.html

相关文章:

  • Java入门基础学习笔记22——程序流程控制
  • java医院信息系统HIS源码SaaS模式Java版云HIS系统 接口技术RESTful API + WebSocket + WebService
  • 2024年成都高新区支持企业申报国家、省级、市级大数据产业发展、新一代信息技术与制造业融合发展、工业互联网推广应用等试点示范项目申报对象条件和奖补
  • 让《行列视》解放数据力量,提升业务洞察
  • LeetCode 每日一题 ---- 【2244.完成所有任务需要的最少轮数】
  • 【RAG 去噪】引入 NLI 模型来为 RAG 去噪
  • SQLite利用事务实现批量插入(提升效率)
  • 使用Python处理Excel数据:去除列中的双引号
  • 未来互联网:Web3的技术革新之路
  • 【练习】分治--快排思想
  • Unity读书系列《Unity高级编程:主程手记》——C#技术要点
  • Redis分片集群
  • Math.Round()函数说明
  • 001 定期同步mysql数据到es 删除数据库记录同时删除es记录 es全文搜索分词和高亮
  • Vue 快速入门:Vue初级
  • 什么是IP跳变?
  • Linux服务器lvm磁盘管理fdisk和df磁盘大小不同修改
  • AOP是什么和OOP的区别
  • Clickhouse 字符串函数 - 2
  • 【个人成长】Fitten Code 测试案例分析
  • 管理Anaconda虚拟环境的实用指南
  • python如何在图片上写斜体字
  • 算法练习第22天|39. 组合总和、40.组合总和II
  • CCF PTA 2022年11月C++大富翁游戏
  • React获取form表单值的N种方式
  • Apache Knox 2.0.0使用
  • Tomcat 内核详解 - Web服务器机制
  • 几个人脸库对于面部动作识别的功能比较
  • IDEA 使用Alibaba Cloud Toolkit 实现远程 自动部署
  • 蓝桥杯备战15.完全二叉树的权值