Http connection problem

Hello

I have some problems with httpconnection. I have to make 2 connections, first to retrieve data from a web service. The second is used to play audio data stream.

Here's what I do:

First of all, I call a web service using a httpconnection (this works well):

HttpConnection httpConn = (HttpConnection)Connector.open(sLocator, Connector.READ);InputStream is = oHttpConn.openInputStream();byte[] loadedContent = IOUtilities.streamToBytes(is);ByteArrayInputStream bytestream = new ByteArrayInputStream(loadedContent);

// Some work with the bytestream

is.close();httpConn.close();

Later in the code, I do in a separate thread:

HttpConnection httpConn =(HttpConnection)Connector.open(sLocator);
InputStream is = httpConn.openInputStream();

player = Manager.createPlayer(is, "audio/mpeg");                                                           player.realize();
player.prefetch();
player.start();

My problem is that this second httpconnection only works if I'm not the first one before (the web service call) (actually only when I comment the web service call the player does his job).

Am I missing something?

I'm working on a simulator at the moment (with SDM launched), I didn't add the parameter "deviceside" to my URL.

However if I join '; deviceside = true' for the second connection, it works sometimes, but only if I use it in the first connection.

Can you help me?

Thank you

Franck

Hello

Are you running the connection of two in the same thread? If this isn't the case, I make sure that the first thread of the connection was closed successfully without exception.

Also, you must add the transport protocols to your all URLS.

I have the same situation when I make two API calls where the 2nd call API is based on the outcome of the first and I do it in the same thread of connection and it works fine.

Tags: BlackBerry Developers

Similar Questions

  • HTTP connection problem. What is going on?

    I am trying to write a simple program to test the validity of the URL via a http connection.

    For the good URL, the program works very well.

    Bad URL however found two ways:

    1: no answer at all (program runs as if nothing happened, waiting for user input.) The text in the EditField is the same incorrect url intentionally being tested)

    2: IllegalArgumentException in RIMConnector.open (int, int, String, boolean, FirewallContext) line: 76.

    What is going on?

    Here is the code:

    import java.io.IOException;
    import javax.microedition.io.Connector;
    import javax.microedition.io.HttpConnection;
    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.component.*;
    import net.rim.device.api.ui.container.*;
    import net.rim.device.api.ui.UiApplication;
    
    final class UrlCheck extends UiApplication {
        private EditField urlField;
        public static void main(String[] args) {
            UrlCheck theApp = new UrlCheck();
            theApp.enterEventDispatcher();
        }
    
        public UrlCheck() {
            MainScreen theScreen = new MainScreen();
            LabelField title = new LabelField("URL Check");
            theScreen.setTitle(title);
    
            urlField = new EditField("URL: ", "", Integer.MAX_VALUE, BasicEditField.FILTER_DEFAULT);
            theScreen.add(urlField);
    
            FieldChangeListener listenerCancel = new FieldChangeListener() {
                public void fieldChanged(Field field, int context) {
                    String URL = urlField.getText();
                    HttpConnection conn = null;
                    int response = 0;
                    try {
                        conn = (HttpConnection)Connector.open(URL);
                        conn.setRequestMethod(HttpConnection.GET);
                        response = conn.getResponseCode();
                        if (response == 200){
                            Dialog.inform("URL OK");
                            return;
                        }
                        if(response == 401){
                            Dialog.inform("URL Requires Authorization");
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                        Dialog.inform("Bad URL");
                    }
                }
            };
            ButtonField checkUrl = new ButtonField("Check");
            checkUrl.setChangeListener(listenerCancel);
            theScreen.add(checkUrl);
            pushScreen(theScreen);
        }
    }
    

    Okay, that was stupid.

    I caught the IllegalArgumentException as well and it fixed the problem.

  • Get Cookies from a HTTP connection problem?

    Hi all!

    I'm trying to get the Http cookie header. This is my code to display the header

    for (int j = 0; j)< 20;="" j++)="">
    Key of type string = httpConn.getHeaderFieldKey (j);
    String field = httpConn.getHeaderField (j);
    If (key == null & j > 0) {}
    break;
    }
    Add (new RichTextField (key + ":" + field));
    }

    But I do not see the 'Set-Cookie' value in my put

    and here is my out put

    connection: close
    x LENGTH: 63
    Server: WEBrick/1.3.1 (Ruby/1.8.7/2009-12-04)
    Date: Friday, April 23, 2010 03:26:30 GMT
    content-length: 7985
    x-rim-etag: "FF10B6C22FA4460C654348D3E2565567D074FEE".
    cache-control: private, max - age = 0, must-revalidate
    ETag: "da5b76f5d045b108fe65b0dfb2a123d8".
    Content-location: http//192.168.11.14:15002/products
    content-type: text/html; charset = utf-8

    Thanks in advance!

    Server fixed the Cookie Set in the HTTP headers. otherwise you will never see this value in the response headers.

    Kind regards

    Sudhakar choup

  • Http connection problem... Urgent

    I m new to BB development

    I tried a code to connect to the local server to retrieve the news by sending that some Arguments say n username password, using the POST method. But when I m tryg to get the response from the server I m rather retrieve the source CODE, instead of success or failure in our case.

    I m unable to understand, where I m wrong. I want that you guys help, since I have done any hard work in desinging of the user interface and now I m stuck in connection HTTP, without which I can't move any further.

    When I try 2 recovery of response I String m to fill the Source Code of an HTML page... I need 2 get just a String (success r failure) as mentioned above.

    In the hope of a quick answer correct n

    Thanks in advance!

    String answer ="";

    Well, talk about what was your error in the thread and mark it as resolved.

    Thank you!

  • Problem in the http connection. (simulators 5.0 os blackberry 9000 smartphone)

    Hello friends,

    I am doing my project in Eclipse Platform Version: 3.4.1 4.5 os and I'm using the 8300 Simulator. I use the http connection. When I debug my project, I work correctly. I'm download 8300 same Simulator to test the object. It worked correctly in Simulator 8300.

    but when I try 4.7 and 5.0 for Simulator that I download this Simulator my project does not work correctly the problem of http connection. Someone tell where I'm wrong?

    Thank you

    Ajay.

    also to install BlackBerry JDE 5.0.

  • Problem Timeout of the weird HTTP connection on the BES!

    Nice day

    I seem to be lost on a TCP connection problem.

    Basically, I opened 'a' connection via TCP, and after a period of 120 seconds of inactivity, it is cleaned by the BES. Now, I've read a resource that provides information about a parameter, the "ConnectionTimeout", which I've tried setting 5 minutes (300000 ms). But this does not solve the problem. In addition, I changed a parameter in the MDS, the 'HTTP device connection period' to 300000 (ms) as well. And Ditto for the rimpublic.property file, which is located in the directory config of the BES.

    Everything seems to indicate that the maximum connection time is 120 seconds. Is this correct? This value can be overridden? If this isn't the case, so why give the possibility to increase the time-out period, without going through a sort of validation?

    Advice will be useful, the way I bypassed, now, to renew or create instance login every 90 seconds.

    See you soon,.
    Nik.

    The parameter side pocket allows to reduce the timeout to a value less than the default value set for the BlackBerry Enterprise Server.  May not go beyond what is on the side server.

  • HTTP connectivity from a device problem

    Hello

    I'm working on an application that works with our web server via HTTP and HTTPS.

    As it is a consumer application, we want to operate without MDS, out-of-the-box when a smartphone is purchased at retail with a web access data plan.

    I assumed that this means using direct TCP when a Wi - Fi connection is not available.

    The following code snippet prepares the URL according to the configuration, and opens the connection:

    String fullUrl = (isSecure? ("https://": "http://") + appConfig.getServerHost () + "/" + url + (bbAppState.isWiFiOnly ()? « ; (interface = wifi': "") + (bbAppState.isDeviceSide ()? « ; (deviceside = true': ' ");

    c = (HttpConnection) Connector.open (fullUrl, Connector.READ_WRITE, true);

    Details of equipment and network:

    Feature: 8320
    OS 4.5.0.81
    T-Mobile US network
    Have a data plan (unlimited web and 400 messages)
    Connection preference: Wi - Fi preferred
    No apn is not specified
    Browser and third-party applications downloaded from the App World can access internet via Wi - Fi and EDGE/GPRS with the above parameters

    Tried:

    1. Free Wi - Fi and EDGE: deviceside = true - get "Tunnel failed '.
    2. Free Wi - Fi and EDGE: no deviceside, only the url - get "Tunnel failed '.
    3. No deviceside, only = wifi interface - works with a Wi-Fi connection, reports "The Tunnel failed" when out of range of a Wi - Fi connection.
    4. I tried parameter APN to internet2.voicestream.com just to test - got the same error 'Tunnel failed '.  I would not use it as the browser and other applications need and work when the APN is empty.

    My question is if I'm something wrong or missing something.  My hypothesis is that third-party apps and BlackBerry Internet Service browser.  Is there a way to know?  Is there a way to disable it (for example to make sure that the browser and other applications use it)? Our company has recently become a partner of Alliance of BlackBerry, so we can apply to BlackBerry Internet Service, but I do not understand if this is necessary for consumer applications, or if the consumer applications should rely on direct TCP.

    Any help will be greatly appreciated.

    Thank you

    Sergey

    Use '; deviceside = true ', you must also specify the details of the AFN, the options of the device or in the string you provide with "; deviceside = true '.  If you do not, you will get "Tunnel failed '.

    I would like to confirm the settings for T-Mobile APN - the value that you used does not match what I found in a google search.

    Browser and other applications will use WAP 2.0 or BIS - B, requiring no configuration.  You can use WAP 2.0 - standard article for more details:

    What - in different ways to establish an HTTP connection or socket
    DB-00396
    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/What_Is...

    Recommendation - use BIS-B (service Alliance Partner) If you can, work in cases more than anything else.

  • Problems with HTTP connections in 7.0

    Hi all

    HTTP connections in my work of fine application with 5.0 and 6.0, but they do not work with 7.0.  Enough actually, they work with 7.0 when the device is connected with WiFi, but not with 3G (Sprint) mobile network.  Connections are also running smoothly on the Simulator.  When the application tries to perform an HTTP request, it seems to open the connection, but the connection hangs just until it expires in a minute later.

    I'm unable to debug applications with the SDK 6.0 and 7.0 in Eclipse.  The debug mode is always suspended my environment.

    Can someone speculate as to why this might be the case?  For added convenience, my code is below:

    public class HttpRequest extends Thread {
        private String method; // GET or POST
        private RequestResults screen;
        private String url;
        private Loader loader;
    
        public HttpRequest(String url, String method, RequestResults screen) {
            this.url = url;
            this.method = method;
            this.screen = screen;
        }
    
        private void connection() {
            // The following code will only build under JDE 4.5 and later
            ByteArrayOutputStream out = null;
            HttpConnection conn = null;
            InputStream in = null;
    
            try {
    
                conn = (HttpConnection) Connector.open(url
                        + ConnectionParams.getConnection());
                conn.setRequestMethod(method);
    
                int responseCode = conn.getResponseCode();
    
                // Check for both 200 AND 201
                if (responseCode != 200 && responseCode != 201) {
    
                    loader.stop();
    
                    Notify.inform(Constants.CONNECTION_LOST);
    
                    conn.close();
                    return;
                }
    
                out = new ByteArrayOutputStream();
    
                in = conn.openInputStream();
                byte[] buffer = new byte[20000];
                int bytesRead = 0;
                while ((bytesRead = in.read(buffer)) > 0) {
                    out.write(buffer, 0, bytesRead);
                }
    
                screen.requestSucceeded(new String(out.toByteArray()));
                loader.stop();
    
            } catch (IOException ex) {
                Notify.inform(Constants.CONNECTION_LOST);
                loader.stop();
            } finally {
                if (in != null) {
                    try {
                        in.close();
                    } catch (IOException e) {
                    }
                }
                if (out != null) {
                    try {
                        out.close();
                    } catch (IOException e) {
                    }
                }
                if (conn != null) {
                    try {
                        conn.close();
                    } catch (IOException e) {
                    }
                }
            }
    
        }
    
        public void run() {
    
            if (NetworkCheck.radioCheck() || NetworkCheck.wifiCheck()) {
    
                loader = LoaderStore.orderLoader();
                loader.start();
                connection();
    
            } else {
                Notify.inform(Constants.NETWORK_ERROR);
            }
    
        }
    
    public class ConnectionParams {
    
        /**
         * The getConnection() method will retrieve the available connection, and is
         * prioritized fastest to slowest connections.
         *
         * @return The connection parameters string to be appended to the HTTP
         *         connection
         */
        public static String getConnection() {
            String connectionParameters = "";
    
            if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) {
                // Connected to a WiFi access point
                connectionParameters = ";ConnectionTimeout=10000;interface=wifi";
            } else {
                int coverageStatus = CoverageInfo.getCoverageStatus();
                ServiceRecord record = getWAP2ServiceRecord();
                if (record != null
                        && (coverageStatus & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT) {
                    // Have network coverage and a WAP 2.0 service book record
                    connectionParameters = ";ConnectionTimeout=10000;deviceside=true;ConnectionUID="
                            + record.getUid();
                } else if ((coverageStatus & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS) {
                    // Have an MDS service book and network coverage
                    connectionParameters = ";ConnectionTimeout=10000;deviceside=false";
                } else if ((coverageStatus & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT) {
                    // Have network coverage but no WAP 2.0 service book record
                    connectionParameters = ";ConnectionTimeout=10000;deviceside=true";
                }
            }
            return connectionParameters;
    
        }
    
        private static ServiceRecord getWAP2ServiceRecord() {
            ServiceBook sb = ServiceBook.getSB();
            ServiceRecord[] records = sb.getRecords();
    
            for (int i = 0; i < records.length; i++) {
                String cid = records[i].getCid().toLowerCase();
                String uid = records[i].getUid().toLowerCase();
                if (cid.indexOf("wptcp") != -1 && uid.indexOf("wifi") == -1
                        && uid.indexOf("mms") == -1) {
                    return records[i];
                }
            }
    
            return null;
        }
    }
    

    The culprit seems to be adding the line

    ConnectionUID = record.getUid ();

    for my URL when you set the connection settings:

    if (record != null && (coverageStatus & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT) {
    // Have network coverage and a WAP 2.0 service book record
        connectionParameters = ";ConnectionTimeout=10000;deviceside=true;ConnectionUID="
        + record.getUid();
    }
    

    Once I have remove this, it works fine...

  • Problem with JavaBean open HTTP connection failed

    Hi all

    With the help of forms 10g (10.1.2.0.2) I followed the tutorial on Francois Degrelle blog 'a java popup of entry dialog box enter a value' (http://fdegrelle.over-blog.com/ext/http: / / sheikyerbouti.developpez.com/index_en/) on the use of a JavaBean in the forms. When I run the form locally on Windows (XP sp2), it is not working. I get the following stacktrace on the Java console.


    java.lang.ClassNotFoundException: java.io.IOException: open HTTP connection failed.

    at sun.applet.AppletClassLoader.getBytes (unknown Source)

    in sun.applet.AppletClassLoader.access$ 100 (unknown Source)

    to sun.applet.AppletClassLoader$ 1.run (unknown Source)

    at java.security.AccessController.doPrivileged (Native Method)

    at sun.applet.AppletClassLoader.findClass (unknown Source)

    at sun.plugin.security.PluginClassLoader.findClass (unknown Source)

    at java.lang.ClassLoader.loadClass (unknown Source)

    at sun.applet.AppletClassLoader.loadClass (unknown Source)

    at java.lang.ClassLoader.loadClass (unknown Source)

    at java.lang.ClassLoader.loadClassInternal (unknown Source)

    at java.lang.Class.forName0 (Native Method)

    at java.lang.Class.forName (unknown Source)

    at oracle.forms.handler.UICommon.instantiate (unknown Source)

    at oracle.forms.handler.UICommon.onCreate (unknown Source)

    at oracle.forms.handler.JavaContainer.onCreate (unknown Source)

    at oracle.forms.engine.Runform.onCreateHandler (unknown Source)

    at oracle.forms.engine.Runform.processMessage (unknown Source)

    at oracle.forms.engine.Runform.processSet (unknown Source)

    at oracle.forms.engine.Runform.onMessageReal (unknown Source)

    at oracle.forms.engine.Runform.onMessage (unknown Source)

    at oracle.forms.engine.Runform.sendInitialMessage (unknown Source)

    at oracle.forms.engine.Runform.startRunform (unknown Source)

    at oracle.forms.engine.Main.createRunform (unknown Source)

    at oracle.forms.engine.Main.start (unknown Source)

    at sun.applet.AppletPanel.run (unknown Source)

    at java.lang.Thread.run (unknown Source)

    When I compile and run the form on our test on Unix server, it works fine. I tried to disable the Windows Firewall, but I get the same error.

    Any idea?

    Published by: genyv80 on August 5, 2010 15:57

    As I said, if you use the Sun plug-in, you MUST add the name of the jar file to the tag archive .

    François

  • connection problems with the version 6.18.0.106

    Hello

    I have Windows XP and I have always used an earlier version of Skype, but now the old version is retired and I can't use it. So I download the new version 6.18.0.106, but this one has a connection problems. Every 4 seconds, I am offline and then online again for 4 seconds. My connection is OK and my provider does not block Skype calls. Is there anyone who knows how to fix?

    Try to uninstall the latest version and install the older version of Skype 6.14.0.104:

    http://download.Skype.com/MSI/SkypeSetup_6.14.0.104.msi

  • Connection problems: Win7, Skype 6.14

    Hello

    I had connection problems since just after I did a windows update last night. (no idea if it's just a coincidence?)

    I read through several other posts here, tried reinstalling Skype several times (also re-installed an older version), checked the compatibility mode and still no joy. Oh, I restarted a few times too.

    I'm trying to connect using my Skype username and password (I don't have an account of ms) but the screen is just stuck there, it says signing in and the whirly thing (term techy lol) is just Dervishes round and round.

    I luuuurv my Skype, absolutely essential for me because I work from home, so I hope someone can help. PLEEEEASE :-)

    Thank you

    Try to uninstall the currently installed version and install the older version of Skype 6.9.0.106 using this msi installer:

    http://download.Skype.com/MSI/SkypeSetup_6.9.0.106.msi

  • LJ pro M177fw: eprint center connection problem

    Hello

    today I am trying to add my new printer to my eprint account, but I do not remember my pwd, so I want to co reset the password.

    By e-mail, I received a link

    http://h30495.www3.HP.com/reset_password/xxxxxxxxxxxxxxx

    but it didn't work, the Web server show this error:

    SERVER ERROR

    Oops! Only, something was wrong with our server.

    Try refreshing the page.

    I tried different browser and pc, but I can not reset my pwd.

    Is there a solution to this problem?

    Is the server down for ever?

    Thank you and best regards.

    Roberto

    Hey @Roberto_ITALY,

    Thanks for posting in the Forum from HP Support.

    I understand that you are unable to claim your HP Color LaserJet Pro MFP M177fw in your account ePrint Center due to a connection problem.  I would like to help.

    I don't see this particular error with password resets from time to time.  I have a workaround that can clear up this place for you:

    • Click here.  This will bring you to <www.snapfish.com >.  As the Snapfish site is linked directly with ePrint Center and HP connected, you can try to reset your password as follows - click the connection icon and then "forgot your password":

    • Enter the e-mail address that you use to connect to the ePrint Center and click on submit.
    • You should receive a message of automatic reset of password by email - the reset as expected before and then try to use this new password to Snapfish to connect downtown ePrint.
    • If this does not solve your problem of access ePrint Center, please call our Cloud Services to 855-785-2777. If you do not live in the United States / Canada region, please click the link below to get help from your region number.

      http://WWW8.HP.com/us/en/contact-HP/WW-phone-assist.html

    I hope this helps.  If my suggestion worked in your favor, feel free to give me a virtual h.o.t. by clicking on the 'Thumbs Up' icon below.

    Have a great day!

  • I have century link hi speed and everytime I turn on my computer it says unable to connect internet connection problem

    I have a hp laptop laptop new g4-1229dx and I have century link for my provider it maintains to disconnect myself from the internet need could be the problem

    Hello Terry,

    Welcome to the Microsoft community where you can find all the answers related to windows.

    According to the description, it seems that you are facing a problem when the network connection with century link hi speed.

    It would be awesome if you could answers to these questions in order to help you further.

    1. which version of the Windows operating system is installed on your computer?

    2 have you made changes on the computer before this problem?

    I suggest you to see the steps in the following Microsoft article and check if it helps.

    Problems in Windows wireless and wired network connection: http://windows.microsoft.com/en-US/windows/help/wired-and-wireless-network-connection-problems-in-windows

    If you need Windows guru, do not hesitate to post your questions and we will be happy to help you.

  • Yahoo Mail sign of trouble, the message appears "diagnose the connection problem.

    When I click on Yahoo Mail sign in the message comes to "diagnose the connection problem. It opens on more of the page. It is only with Yahoo Mail.  All other centers opened their doors without refreshing the page.  This problem is with all browsers. Any solution please.

    Hello

    Because the problem is with yahoo mail I suggest you to ask your question in the forums of yahoo.
    http://answers.Yahoo.com/dir/index?link=list&SID=396546091

  • I got these messages: "Sorry, there is a problem with Hotmail right now"... "Hotmail is having connection problems.

    I got these messages: "Sorry, there is a problem with Hotmail right now"... "Hotmail is having connection problems. You might see an error message when you try to connect.

    original title: cannot access Hotmail

    I need to go to my account to retrieve an important document for a meeting! Please advise how can I sing to my account?

    Hello

    The Hotmail service problems. See the following link to check the status of the service.

    Status of hotmail - Windows Live: https://status.live.com/detail/hotmail

    Once the service has been restored, there will be a notice at this link.

    Concerning

Maybe you are looking for

  • Satellite A100-383 does not - the battery is not

    Hi all I own a satellite A100-383 (PSAARE) that does not start when the battery is totally empty, or if I leave without the battery of the day to the next. The battery will charge not façade is and all the lights are off. I should always have a load

  • pavilion17-p001na: lost factory reset

    I received an email that I thought me Microsoft I opened it and it asked me to connect my account of microsoft access to the new free offers. I did and restarted the laptop. When she came back just froze I put the recovery discs, I had and a message

  • A key is damaged on my satellite M30x

    I have a X 30 M and the "s" on my keyboard key, is damaged, the black surface does not have the white support. Now, can I buy just this key or I have to buy all the keyboard? Thank you Chaves

  • Permission denied error when you use the Matlab script

    I have the following simple running a Matlab script in Labview. K = 5;Matrix = randn (4,4);matlab.io.saveVariablesToScript ('Parameters.m', {'K', 'Matrix'}) the last command saves the variables 'K' and 'Matrix' in the m-settings file that I can then

  • Downgrading to XP on Presario V6320CA

    Hello I want to downgrade my Presario V6320CA from Vista to XP. Where can I find the necessary drivers? Data sheet: 1.60 ghz AMD Turion 64 Dual core 1 GB of RAM Windows VISTA 32-bit Service Pack 1 I tried downgrading to XP before, but missed me two o