Blackberry HTTP Connection Issue

▼魔方 西西 提交于 2019-12-13 12:50:39

问题


I have a simple app written the connects to web service (restful). The app works fine on the blackberry simulator however I'm having problems using it on a blackberry 9300.

I keep getting the error "java.io.ioexception: tunnel down" when the apps attempts to call the web service.

The service I am calling is a simple HTTP post and I'm trying to run this over WIFI (the WIFI connection is working fine for browsing the internet).

I'm using a connection string of "http://127.0.0.1:8080/test/restws;interface=wifi" with the IP address changed to the actual Ip address of the server I'm calling. I can call the restful web service on this server on my laptop browser fine.

The code Im using is similar to below & works fine on the simulator. The only thing im changing between the simulator and the code on the phone is the connection string (using "interface=wifi" as oppose to "deviceside=true")

Is this a code problem or is it a setting I need to change on the handset? Any ideas on what I need to do to overcome this.

Thanks

    StreamConnection s = (StreamConnection) Connector
        .open(connectionString);
    httpConn = (HttpConnection) s;
    httpConn.setRequestMethod("POST");
    httpConn.setRequestProperty("Content-Length", Integer.toString(postData.length()));

    OutputStream output = httpConn.openOutputStream();
    output.write(postData.getBytes());
    output.flush();
    output.close();

    String response = httpConn.getResponseMessage();
    int statusCode = httpConn.getResponseCode();
    if (statusCode != HttpConnection.HTTP_OK) {
    }

    InputStream is = httpConn.openInputStream();
    int ret = 0;
    while ((ret = is.read(buf)) > 0) {
    os.write(buf, 0, ret);
    }

    result = new String(os.toByteArray());

回答1:


I had problems in here .After getting HttpConnection everything is the same i guess. Try this:

ConnectionFactory cf = new ConnectionFactory();
ConnectionDescriptor cd = cf.getConnection("YourUrl");
httpConnector = (HttpConnection) cd.getConnection();
httpConnector.setRequestMethod(HttpConnection.POST);



回答2:


Hey well i donot know if it would solve your problem but try this tag too with the interface=wifi, deviceside=true and also "ConnectionType=mds-public". Hope it works.Cheers




回答3:


Network connections on the BlackBerry are convoluted and hard. The de facto guide on how it all works is the forum post "Connecting your BlackBerry - http and socket connections to the world" by Peter Strange.

In addition, there is at least a partial description of the "Tunnel Down" error within the post "Connection Problems". You might try searching the BlackBerry support forums for more.




回答4:


read the link : http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/What_Is_-_Different_ways_to_make_an_HTTP_or_socket_connection.html?nodeid=826935&vernum=0



来源:https://stackoverflow.com/questions/6861036/blackberry-http-connection-issue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!