Hello Daniel,
Thank you very much for your response. Here the portions for my websocket config. Of
course all needed modules are loaded (one modparam for websocket ping) and I took the
config all from
http://kamailio.org/docs/modules/4.3.x/modules/websocket.html:
onreply_route[WS_REPLY] {
if (nat_uac_test(64)) {
add_contact_alias();
}
if (proto==WS) {
xlog("L_INFO", "Hit Reply from
Websocket");
rtpengine_answer("trust-address ");
}
}
event_route[xhttp:request] {
set_reply_close();
set_reply_no_connect();
if ($Rp != MY_INTERN_WSPORT){
xlog("L_WARN", "HTTP request received on
$Rp\n");
xhttp_reply("403", "Forbidden",
"", "");
exit;
}
if ($hdr(Upgrade)=~"websocket" &&
$hdr(Connection)=~"Upgrade" && $rm=~"GET") {
if ($hdr(Host) == $null || !is_myself("sip:" +
$hdr(Host))) {
xlog("L_WARN", "Bad host
$hdr(Host)\n");
xhttp_reply("403",
"Forbidden", "", "");
exit;
}
if (ws_handle_handshake()) {
exit;
}
}
xhttp_reply("404", "Not Found", "",
"");
}
event_route[websocket:closed] {
xlog("L_INFO", "WebSocket connection from $si:$sp has
closed\n");
}
I have attached a debug log for the registration process over websocket, on line 49 you
can see the error.
As for the INVITE I use now this:
if ($rU=~"^3$" && src_ip==$sel(cfg_get.pstn.gw_ip)) {
$ru = "sip:dnagorny@10.250.5.74";
uac_replace_to("sip:dnagorny@10.250.5.74");
rtpengine_offer("external internal trust-address");
route(RELAY);
}
Unfortunately I can see now that Kamailio tries to send it out on 10.250.5.74:5060, which
I am not even listening on. For the route(RELAY) I use this:
route[RELAY] {
if (is_method("INVITE")) {
t_on_branch("MANAGE_BRANCH");
if (proto==WS) {
t_on_reply("WS_REPLY");
} else {
t_on_reply("MANAGE_REPLY");
}
t_on_failure("MANAGE_FAILURE");
}
if (is_method("CANCEL|BYE")) {
rtpengine_delete();
}
if (!t_relay()) {
sl_reply_error();
}
exit;
}
Is t_relay for Websocket the right choice? I somehow have my doubts but couldn't find
any suggestion in the documentation. Additional Info: Outgoing calls from Websocket
registered Users are working.
Thanks for your time helping me out.
Best Regards
Dimitry Nagorny
Trainee
Von: sr-users [mailto:sr-users-bounces@lists.sip-router.org] Im Auftrag von
Daniel-Constantin Mierla
Gesendet: Freitag, 3. Juni 2016 08:36
An: Kamailio (SER) - Users Mailing List <sr-users(a)lists.sip-router.org>
Betreff: Re: [SR-Users] Kamailio Websocket Questions
Hello,
1. for websocket the connection has to be reused, the server cannot open a connection
towards the browser. So you don't have to force any socket, if kamailio doesn't
find the address matching the target ws address, then will throw an error, otherwise will
use it.
2. have you enabled xhttp and websocket modules properly?
Cheers,
Daniel
On 02/06/16 17:13, Nagorny, Dimitry wrote:
Hi List,
two questions regarding Kamailio Websockets:
1. How do I send INVITE request TO the listening Websocket?
I usually used for UDP/TCP/TLS these format, but somehow this is not working for Websocket
because it gets in an endless loop:
if ($rU=~"^(\+|00|0)?[1-9][0-9]{4,20}$") {
$ru = "sip:" + $rU + "@" + $sel(cfg_get.pstn.gw_ip) +
";user=phone;transport=udp";
force_send_socket(udp:MY_EXTERN_IP:MY_EXTERN_PORT);
rtpengine_offer("internal trust-address RTP AVP");
route(RELAY);
exit;
}
2. Why do I get these errors every time my Websocket Client is registering, but it
still works and DB is inserted with registered location:
ERROR: <core> [parser/parse_fline.c:257]: parse_first_line(): parse_first_line: bad
message (offset: 22)
ERROR: <core> [parser/msg_parser.c:690]: parse_msg(): ERROR: parse_msg:
message=<HTTP/1.1 101 Switching Protocols#015#012Sia: SIP/2.0/TCP
10.250.5.17:51283#015#012Sec-WebSocket-Protocol: sip#015#012Upgrade:
websocket#015#012Connection: upgrade#015#012Sec-WebSocket-Accept:
6uLXlD/aBrzu/j3PYP3DWO7rvLE=#015#012Server: kamailio (4.3.5
(x86_64/linux))#015#012Content-Length: 0#015#012#015#012>
I am using Kamailio 4.3.5 + CentOS 7.2. I appreciate every help I can get.
Best Regards
Dimitry Nagorny
Trainee
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org<mailto:sr-users@lists.sip-router.org>
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
--
Daniel-Constantin Mierla
http://www.asipto.com -
http://www.kamailio.org
http://twitter.com/#!/miconda -
http://www.linkedin.com/in/miconda