问题
I have a MIDlet that sends TCP messages over the network to a server residing on the same internal network. Whenever I try to connect using this line:
StreamConnection writeSock = (StreamConnection) Connector.open("socket://" + serverIp + ":" + serverPort, Connector.READ_WRITE);
I get an error saying
Tunnel Failed
According to netstat, the port on which the server is set to listen is actually open and in listening mode. I printed the IP and Port values from the mobile application and they seem to be correct. I have looked on the internet and many people solved the problem by setting up their APN details. I did such a thing, and the problem still persists. I have no clue what I have to do next. Just for checking purposes, these are the APN details I entered:
APN: internet Username for APN: internet Password for APN: internet
My carrier is Vodafone Malta. Just as a side note, this part of the application works on an emulator. I am using a default emulator (DefaultFxPhone1) that comes with the j2me package, and I am using Netbeans 6.8.
I have tried enabling and disabling the firewall, but to no avail.
Thanks in advance.
回答1:
You may also want to consider trying adding the ";deviceside=true" parameter to the end of the connection string. The default is false, which implies MDS (BES infrastructure). To do direct TCP over the APN, you need to set it to true.
回答2:
"Tunnel failed" means that your APN is not configured properly in the device. You may need to do some Googling to find the proper APN for your carrier.
来源:https://stackoverflow.com/questions/2362545/tunnel-failed-blackberry-curve-8900