PJSIP and stateless outbound proxy - proxy

I am experimenting with PJSIP on my LAN. My setup is 2 clients running on different sip ports with stateless_proxy
Client 1:
./pjsua-x86_64-unknown-linux-gnu --no-tcp --local-port=5060 --outbound=sip:192.168.2.31:6060
Client 2:
./pjsua-x86_64-unknown-linux-gnu --no-tcp --local-port=7070 --outbound=sip:192.168.2.31:6060
Proxy:
./stateless_proxy -p 6060
Source code: https://github.com/pjsip/pjproject/tree/2.12.1
When i Try to give a call from client 1 to client 2, the INVITE goes to proxy but not received on client 2
Digging into the code I found proxy could not find transport for client2.
I believe I am missing something in my setup but not sure what.
I tried searching the internet but all I could find was some configuration for FreePBX or Asterix.
Any pointers would be helpful.
Thanks in advance...
Log from Proxy:
03:11:14.075 sip_resolve.c .Target '192.168.2.31:7070' type=Unspecified resolved to '192.168.2.31:7070' type=UDP (UDP transport)
03:11:14.075 endpoint .Request msg INVITE/cseq=313 (tdta0x7ffff0002b58) exceeds UDP size threshold (1300), sending with TCP
03:11:14.075 tdta0x7ffff0002b58 .Destroying txdata Request msg INVITE/cseq=313 (tdta0x7ffff0002b58)

Related

How to deploy and interact with a rust websocket?

I'm a beginner in Rust and WebSockets and I'm trying to deploy on Heroku a little chat backend I wrote (everything works on localhost). The build went well and I can see the app is running, and I'm now trying to connect to the WebSocket from a local HTML/Javascript frontend, but it is not working.
Here is my code creating the WebSocket on my rust server on Heroku (using the tungstenite WebSocket crate):
async fn main() -> Result<(), IoError> {
let port = env::var("PORT").unwrap_or_else(|_| "8080".to_string());
let addr = format!("0.0.0.0:{}", port);
// Create the event loop and TCP listener we'll accept connections on.
let try_socket = TcpListener::bind(&addr).await;
let listener = try_socket.expect("Failed to bind");
println!("Listening on: {}", addr);
and here is the code in my Javascript file that tries to connect to that WebSocket:
var ws = new WebSocket("wss://https://myappname.herokuapp.com/");
My web client gets the following error in the console:
WebSocket connection to 'wss://https//rocky-wave-51234.herokuapp.com/' failed
I searched to find the answer to my issue but unfortunately didn't find a fix so far. I've found hints that I might have to create an HTTP server first in my backend and then upgrade it to a WebSocket, but I can't find a resource on how to do that and don't even know if this is in fact the answer to my problem. Help would be greatly appreciated, thanks!
I think your mistake is the URL you use:
"wss://https://myappname.herokuapp.com/"
A URL usually starts with <protocol>://. The relevant protocols here are:
http - unencrypted hypertext
https - encrypted hypertext
ws - unencrypted websocket
wss - encrypted websocket
So if your URL is an encrypted websocket, it should start only with wss://, a connection cannot have multiple protocols at once:
"wss://myappname.herokuapp.com/"

Poloniex Push WAMP API through Autobahn dropping connection to peer tcp

I tried to connect to the Push API in poloniex using python and followed the instructions on the answer here:
How to connect to poloniex.com websocket api using a python library
However I keep getting this error:
2017-06-25T04:07:04 dropping connection to peer tcp:104.20.13.48:443 with abort=True: WebSocket opening handshake timeout (peer did not finish the opening handshake in time)
Anyone know what's going on here? I can't figure it out from online documentation. Thanks!
As per #Cyphrags suggestion, I was able to get my autobahn websocket to work outside of localhost by increasing openHandshakeTimeout with factory.setProtocolOptions
factory.protocol = MyClientProtocol
factory.setProtocolOptions(failByDrop=False, openHandshakeTimeout=90, closeHandshakeTimeout=5)
Solution found via https://github.com/crossbario/crossbar/issues/930. Perhaps the reason it is needed has something to do with slow DNS routing taking longer than the default handshake time.

Connecting ibm bluemix watson IoT using erlang mqtt websocket client on port 443

MQTT over Websocket protocol
I'm trying to connect IBM Watson IoT service using erlang mqtt websockets on port 443(ssl/tls). But, I was receiving error.
The IBM dos(https://console.ng.bluemix.net/docs/services/IoT/iotplatform_task.html#devices) says that it support websocket connection. There is no mention of the websocket usage(tutorials/guide) except normal tcp connection(which i was successfull at getting conected).
I want a simple step by step doc like the Amazon IoT (http://docs.aws.amazon.com/iot/latest/developerguide/protocols.html) for websocket connectivity as a client application.
I'm figuring about the URL/URI which I think might be improper i.e ws(s)://host:port/path.
Currently, i'm giving it as wss://fybr123mqtt.mybluemix.net
(where fybr123mqtt is my application name).
What is the host, port & path for connecting to IBM Watson IoT through mqtt ?
And how to send other parameters like 'client_id', 'username', 'password', 'authentication token' along with the HOST ?
Also, suggest some erlang websocket client for mqtt and also mention simple steps to access the websocket server. Erlang mqtt client (emqttc) does not support websocket.
The connection process is clearly described here:
console.ng.bluemix.net/docs/services/IoT/devices/mqtt.html
The URL that you mentioned is not correct: wss://fybr123mqtt.mybluemix.net
On Step 2: Connecting your devices to Watson IoT Platform from console.ng.bluemix.net/docs/services/IoT/iotplatform_task.html#devices it says the following:
The following information is required when connecting your device:
URL: org_id.messaging.internetofthings.ibmcloud.com
Where org_id is the ID of your Watson IoT Platform organization.
Port:
1883
8883 (encrypted)
443 (websockets)
Device identifier: d:org_id:device_type:device_id
This combination of parameters uniquely identifies your device.
Username: use-token-auth
This value indicates that you are using token authorization.
Password: Authentication token
This value is the unique token that you defined or that was assigned to your device when you registered it.
The org_id, device_type, device_id and password are provided after you complete Step 1: Registering your device with Watson IoT Platform
Note: The clienID is Device identifier: d:org_id:device_type:device_id
I successfully used mqttfx, eclipse paho, mosquitto and there are a lot of other free mqtt clients that you can use.
Also, there are good tutorials (recipes) that can help you get starter with IBM's client libraries in Java, Pyhton, etc. As examples you can have a look on:
"ibm.com/developerworks/cloud/library/cl-mqtt-bluemix-iot-node-red-app/"
Here is an example for gateway device type with mosquitto
"developer.ibm.com/recipes/tutorials/using-mosquitto-as-a-gateway-for-watson-iot/"
Lets not forget the client nodes from NodeRed, that are very easy to use.
Let me know if you still need help on this.
Thanks,
Daniel
Url: wss://6DigitOrgID.messaging.internetofthings.ibmcloud.com:8883
It works fine using NodeJS. I don't specify a further endpoint.
[BaseClient:connect] Connecting to IoTF with host : wss://6DigitOrgID.messaging.internetofthings.ibmcloud.com:8883
[DeviceClient:connect] DeviceClient Connected
connected
[DeviceClient:publish] Publishing to topic iot-2/evt/myevt/fmt/json with payload {"radiation":1} with QoS 2
This is based off the sample client code with "enforce-ws" : true
I modified that client and tested with 443 also:
[BaseClient:connect] Connecting to IoTF with host : wss://6DigitOrgID.messaging.internetofthings.ibmcloud.com:443
[DeviceClient:connect] DeviceClient Connected
connected
[DeviceClient:publish] Publishing to topic iot-2/evt/myevt/fmt/json with payload {"radiation":1} with QoS 2
I don't know of any samples for erlang.

Set fixed rport in FreeSWITCH/Sofia subscribe message

The problem is that I know next to nothing about SIP, or FreeSWITCH, yet have been tasked with figuring this out.
The setup:
The FreeSWITCH client sends a subscribe to a remote server to receive presence updates. The client is behind a fairly restrictive firewall and NAT.
The server replies with the normal unauthorized, and Sofia replies, and we receive the SIP/2.0 200 OK message, its VIA header contains an rport for a port number we don't have open or forwarding to our FreeSWITCH installation.
We never receive the notify that ought to follow the 200 OK.
Subsequent subscribes returns different rport designations.
Is there a way to configure FreeSWITCH/Sofia to always use a specific port for the rport parameter?
Edit: We never managed to solve it, but the remote service did solve it by adding the correct routes to their firewall.
Is the far end server setup to allow NOTIFY to be sent to your client?
If you receive the 200 OK response to the initial SUBSCRIBE then that sets up the SIP dialog I believe (the dialog is a end-point to end-point association).
BTW you set up FS to be the presence watcher client? Thats cool since I tried doing that but the documentation gave me a headache and moved on to other things.
Since you sent the initial subscribe NAT shouldn't be a problem right? since rport should have the port to use. I would always use port 5060, have your FW people let udp port 5060 port in and out freely, use Fail2ban to filter your traffic.
But have no idea how FS works, and NAT firewalls are the greatest evil :-). Sorry and best of luck.

how to connect http server implemented by the c# socket class

I have finished http protocol via the socket class according to rfc2616 protocol, but how to connect https protocol and send data to server using the socket class?
When i connected https server https://www.example.com, I always get 404 error. The following is the socket command that to send to server https://www.example.com/
GET / HTTP/1.1 Host: www.example.com
the default always use http protocol
I found connected to https server need to use a connect command instead of the Get command and a client certificate. for example:
CONNECT login.example.com:443 HTTP/1.0
Major Version: 3
Minor Version: 1
......
I will try to use the connect command. Thanks for your replies.
==================================================
OK,i have solved my problem ,use the SLStream class.
NetworkStream networkStream=new NetWorkStream(socket)
var stream=New SslStream(networkStream)
.......
Now, will can read stream and write stream, until finished.

Resources