Not able to connect to TCP server through APN - sockets

After googling thoroughly I finally decided to post my problem which is really giving me nightmares.
In my app I am trying to connect to a TCP server using the Network Carrier internet and using following connection string:
url="socket://"+ip+":"+port+";deviceside=true;connectionTimeout=30000;apn=;tunnelauthusername=;tunnelauthpassword=;";
I am able to connect to internet through the phone's browser but not able to connect to TCP server through app.
In my device APN authentication is disabled by default and APN,Userid/Password fields are blank thats why i have taken these parameters as blank valued in the connection string.
When i try to connect through wifi network using the string below:
url="socket://"+ip+":"+port+";deviceside=true;interface=wifi;connectionTimeout=30000";
I am able to connect to server but not in the case via APN.
Please help me out.
I am just stuck here and finding no way out.
Thanks

There are a variety of methods of connecting to a Server. What you are doing is specifying the method to use in the connection suffix which you set. The options that you can use in the connection suffix are documented in the BB KB article here:
Different-ways-to-make-an-HTTP-or-socket-connection
If you are supporting really old phones (pre OS 5.0), then this is the only option you have. But the trick with this is that you have to figure out what connection method is going to work on your device at the time you make the request. There is a load of code floating round the internet to do this, most of it dubious.
If you are OS 5.0 or above, then you can use a more advanced API, the ConnectionFactory, to make this easier, and in OS 6.0 even more advanced features. These are all documented on the BB Java microsite, see here:
BB OS Networking
The option you are using is the GCF framework. I recommend you investigate the "Network API" if you are supporting OS 5.0 and later only. You might also investigate the "Network API alternative for legacy OS".
This does not answer the frequent question, "how come the Browser can connect and I can't in my app?". This is because the Browser uses a special BlackBerry connectivity method referred to as BIS-B. The good thing about BIS-B is that it will work for any BB phone that has a BlackBerry tariff, and requires no configuration. The bad thing is that you do not get access to it as of right. To get access to it, the easiest thing to do is to ask for Push support, even if you are not planning on using it immediately but might in the future. This is documented on the page above.
But back to your question. The APN values in your TCP configuration being not set, does NOT mean you don't have to set them. The values specified in the Options are used as the default values should someone code ";deviceside=true" as a connection string - the idea being that users can set these for themselves and application developers don't code anything. These values are specific to your carrier. So search to find out what values you need to use. You will either put these values in the TCP Options (and so don't code them in your connection suffix), or put in your connection suffix. If you can't find out what you should put in there, you need to ask your carrier.
On most BlackBerry tariffs, using direct TCP through the APN may cost the user something for the data, and will also require configuration. Alternatively, you can use WAP 2, which may also cost for data, but doesn't require any configuration. The advantage of both these is that they will work on phones that are not using a BlackBerry tariff.
My recommendation is to look at connecting using ConnectionFactory (Network API), but this will only work for OS 5.0 and above.

Related

Using VPS to create VPN and using the local Ip address to send (Secure) a get/websocket request

So I have a VPS (Cent Os 7) and using openvpn I created VPN having an address of 10.0.8.1 now on my front end I connected to VPN using openvpn after connecting I get access to websocket on 10.0.8.1 but its not secure I want access to wss on the same address. I have also tried using a secure domain name to connect but it still fails I can only connect it with either http or ws and not with https or wss
This is very trivial as far as a question but all in all, without telling you how to perform anything in details - the question is WWAAAYYY too broad to even consider answering without unevitably creating more questions than solving a problem or helping you.
You need to add cryptography to your websocket server, same as a web server is able to run in HTTPS mode rather than unencrypted. I'm sure you can see the similarity between both abreviations of the respective protocols and how they are different from their original, unencrypted/vulnerable default configuration.
http -> https
ws -> wss
Start reading on adding a SSL certificate to your websocket server config and then you will have a WSS connection - if all goes well of course!
I believe in you
p.s. - this is not the type of question that is very well received by the majority of the community. It is too broad to be of any interrest to anyone.A complete, well-built, comprehensive answer isn't something that fits within the boudaries of most community members as there is WAY too many variables and unknowns here. Anything will most likely create more questions (of this quality) than help you or anyone else. You lack basic knowledge in order to construct a question that doesn't sound anything other than 'i need a full tutorial'. Community doesn't provide tutorials, custom solutions or anything that resssembles a full product/service. We rather help solve smaller, more precise and clear issues that pop up day to day in the field. Generally, when someone "talks the talk", it implies that the bases are covered and an issue arose. For now, you must learn to "walk the walk" i suppose.
Everyone wore the same shoes at some point or another and good memory comes from remembering such stuff from when we started playing with the wall socket angry pixies!
Cheers!

WebRTC on Chrome; how do I know if it's using UDP or TCP

I'm currently playing around with WebRTC on Chrome behind a company firewall, using Google's demo app at: https://apprtc.appspot.com. Is there any sure-fire way to determine whether the connection being made to another app user outside my company firewall is via UDP or streaming TCP through Google's STUN/TURN server? chrome://webrtc-internals provides a lot of stats, but nothing obvious to me. Or is there an API call I can make during the session to determine the transport type? Thanks
=========== UPDATE ==============
FYI, this provides more information - press 'i' when using the demo app will show if using a TURN server (but not if using tcp/udp).
Wireshark will work fine for that. On Firefox, you can go to about:webrtc, click on the peerconnection, and see which candidates from ICE were selected (and if they're TCP or UDP, etc).
[edit - added]
Programmatically, you can look at the type of candidates using statistics reports, such as in this example and this PR and using the type property. You may have to parse the SDP to get the priority from the Candidates in Firefox. (thanks to Fippo for pointing this out).

Push notifications with sockets for desktop WPF aplication (No Win8 App)

I'm trying to get into an implementation of some kind of push notification for a Windows WPF client application and a java backed server.
The idea is to avoid as much as possible polling the server, so I thought to implement it with sockets and messages, and relying in some easy pulling solution in case a socket connection could not be done, (Firewalls, etc).
In the other hand is important that the data traveling get encrypted.
So I have a couple of question/"request for opinions" more related with the WPF client:
Perhaps already exist some solution for that, any tips?
Could be good to think in some SSL sockets connections for that?
If 2 is OK, there is some native solution for secure sockets in .net or any library?
If sockets solutions is an option, I guess i need to go through port 443 and by the way it will avoid many problems with firewalls and so on, am i right?
I know there is many question but all are related to the same problem.
Thanks in advance.
http://clientengine.codeplex.com/
Yes, SSL is good if you need to keep the data secure during transfer
Yes, http://clientengine.codeplex.com/ indicates it supports SSL/TLS
Well, it depends on whether you are controlling the server or not. If you have control over it you can use whatever port you want.

See what website the user is visiting in a browser independent way

I am trying to build an application that can inform a user about website specific information whenever they are visiting a website that is present in my database. This must be done in a browser independent way so the user will always see the information when visiting a website (no matter what browser or other tool he or she is using to visit the website).
My first (partially successful) approach was by looking at the data packets using the System.Net.Sockets.Socket class etc. Unfortunately I discoverd that this approach only works when the user has administrator rights. And of course, that is not what I want. My goal is that the user can install one relatively simple program that can be used right away.
After this I went looking for alternatives and found a lot about WinPcap and some of it's .NET wrappers (did I tell you I am programming c# .NET already?). But with WinPcap I found out that this must be installed on the user's pc and there is nog way to just reference some dll files and code away. I already looked at including WinPcap as a prerequisite in my installer but that is also to cumbersome.
Well, long story short. I want to know in my application what website my user is visiting at the moment it is happening. I think it must be done by looking at the data packets of the network but can't find a good solution for this. My application is build in C# .NET (4.0).
You could use Fiddler to monitor Internet traffic.
It is
a Web Debugging Proxy which logs all HTTP(S) traffic between your computer and the Internet. Fiddler allows you to inspect traffic, set breakpoints, and "fiddle" with incoming or outgoing data. Fiddler includes a powerful event-based scripting subsystem, and can be extended using any .NET language.
It's scriptable and can be readily used from .NET.
One simple idea: Instead of monitoring the traffic directly, what about installing a browser extension that sends you the current url of the page. Then you can check if that url is in your database and optionally show the user a message using the browser extension.
This is how extensions like Invisible Hand work... It scans the current page and sends relevant data back to the server for processing. If it finds anything, it uses the browser extension framework to communicate those results back to the user. (Using an alert, or a bar across the top of the window, etc.)
for a good start, wireshark will do what you want.
you can specify a filter to isolate and view http streams.
best part is wireshark is open source, and built opon another program api, winpcap which is open source.
I'm guessing this is what you want.
capture network data off the wire
view the tcp traffic of a computer, isolate and save(in part or in hole) http data.
store information about the http connections
number 1 there is easy, you can google for a winpcap tutorial, or just use some of their sample programs to capture the data.
I recomend you study up on the pcap file format, everything with winpcap uses this basic format and its structers.
now you have to learn how to take a tcp stream and turn it into a solid data stream without curoption, or disorginized parts. (sorry for the spelling)
again, a very good example can be found in the wireshark source code.
then with your data stream, you can simple read the http format, and html data, or what ever your dealing with.
Hope that helps
If the user is cooperating, you could have them set their browser(s) to use a proxy service you provide. This would intercept all web traffic, do whatever you want with it (look up in your database, notify the user, etc), and then pass it on to the original location. Run the proxy on the local system, or on a remote system if that fits your case better.
If the user is not cooperating, or you don't want to make them change their browser settings, you could use one of the packet sniffing solutions, such as fiddler.
A simple stright forward way is to change the comupter DNS to point to your application.
this will cause all DNS traffic to pass though your app which can be sniffed and then redirected to the real DNS server.
it will also save you the hussel of filtering out emule/torrent traffic as it normally work with pure IP address (which also might be a problem as it can be circumvented by using IP address to browse).
-How to change windows DNS Servers
-DNS resolver
Another simple way is to configure (programmaticly) the browsers proxy to pass through your server this will make your life easier but will be more obvious to users.
How to create a simple proxy in C#?

Use a proxy to connect iPhone to server?

I'm researching how to code an iPhone app that needs to connect to an online service to get data. The online service only provides access to specified IP addresses or ranges, so iPhones won't be able to connect directly, and the request will have to go through a server. I looked into setting up my own forward proxy server (which the service in question are happy with, by the way), which I guess would do the job for most other platforms. Unfortunately the iPhone does not seem to allow configuring a proxy address programmatically. Is there another potential solution for accessing the content from an intermediate server, that would show the online service the IP address of the server, rather than each individual iPhone?
Many thanks
Steve
It appears that using cURL is one way to achieve this. There should be bindings available for Cocoa.
I'll let people know how it goes in the comments.
Steve