Complete closure SocketConnections correctly

Hello

I'm having a problem with a persistent socket connection don't close does not correctly (at least I think that's the problem). Here is my scenario:

I have an iPad, which has an application that listens to incomming socket connections and responds to the need (I'm not in control of this application). Then I on the side of BB. The general idea is, I try to open a connection on WiFi, a specific IP address. If this succeeds, I opened an InputStream and an OutputStream. Some messages are sent back and forth between the two devices (starting with a reading on the River - from the perspective of BB), and then wait for us. The iPad or BB can then initiate communication more. When it does not, the two are pending. Water courses are never closed, unless the BB or iPad outputs, in which case both are closed, as well as the connection.

My problem is the following: if I close the BB app and off the device (i.e. ensuring that the app is completely closed and not only out of focus), then the next time I want to create a connection, it is just forever. Socket error (IOException), I get a general after about 30 years. I have to restart the iPad and try again to make it work again. So it seems that the BB is not completely close the connection, or the iPad is not clean properly. As I am not in control of the iPad code, I can't confirm. However, I think that it is on the side of BB as there is an iOS and Android version of my BB application, and they do not have this problem.

I also noticed that I get the message (s):

Background switch detected for APP_NAME (241) which has called id = 1mode FG = open - solomode DO NOT tunnel

Background switch detected for APP_NAME (241) which has 1 tunnel (s) open - defocus called

When I close the application on the BB.

I use the following code to close the water connections (and make sure that this is called when the application stops):

try {
                if (inStream != null) {
                    inStream.close();
                    inStream = null;
                }
            } catch (Exception e) {
                System.out.println("Error closing instream: " + e.getMessage());
            }
            try {
                if (outStream != null) {
                    outStream.close();
                    outStream = null;
                }
            } catch (Exception e) {
                System.out.println("Error closing outstream: " + e.getMessage());
            }
            try {
                if (connection != null) {
                    connection.close();
                    connection = null;
                }
            } catch (Exception e) {
                System.out.println("Error closing connection: " + e.getMessage());
            }

Another thing to note: I do things in the synchronized blocks, during the opening and closing of connections. I do also all the networks on a separate Thread. I make sure that all exceptions related to this to ensure that connections are closed. The connection, water courses and outstream instances are variable class.

In a main loop, in the non-Main-Event-Thread, I check if the connection is closed, in this case, I wait a few seconds (Thread.sleep), then try opening the connection again. So I'm constantly returning the IP address.

If I ever close the simulator/device and the connection seems to be able to connect/disconnect perfectly, with both applications open, then all closed and opened again, etc.

Is there something I should be aware of the wrt completely closing Sockets, clean it properly, using blocks in sync, etc. ?

I opened the connection as (all this surrounded by the try/catch/finally block and a synchronized block):

               connection = (SocketConnection) Connector.open("socket://" + url + ";interface=wifi", Connector.READ_WRITE, true);
                inStream = connection.openInputStream();
                outStream = connection.openOutputStream();

Thank you very much!

P.S. I've been Googling/search forums since last week, and did not close - I hope that I have not missed anything.

I think I might get a little. I can't believe that I don't check this before. I've installed wireshark to check what WAS going through, etc. I noticed that very little was coming or going to the iPad (even though he could browse the web, etc.). So I tried to make a simple ping of my machine. Nothing. WHAT? So I rebooted the iPad. It worked again... and then stopped? So I rebooted the router... He continued to work. And work... And work...

Without doubt, it stops again. But it seems that there may be nothing wrong with the iPad or BB at all. It could just be something questionable with my router! I have... Can't... Believe not!

I will continue to look into it and watch what is happening... but in the meantime, I'm terribly sorry for wasting your time! * so embarrassed *. Thanks for your help.

PS, I know this isn't the place for this, but if anyone has any ideas as to why this can happen, I would be very grateful to know. It cost me a few days of time wasted dev.

Tags: BlackBerry Developers

Similar Questions

  • Complete closure map

    Hello

    I wonder if it is possible to completely close a card? As in this moment my card just application gets 'pool' which puts the card into a State where it doesn't have either closed or open.

    As I have a webView in my card, I would like (if possible) to completely close the map rather pooling it so that when the card is closed, all content in the Web mode is destroyed so that the next time that the card is opened, the webView itself would be handed so there not the same loaded web page as it did before the closure of the card.

    Thanks in advance

    I have not tested, but try to add.

    In the applicationui.cpp constructor:

        connect(m_invokeManager,
                     SIGNAL(cardPooled(const bb::system::CardDoneMessage&)), this,
                     SLOT(pooled(const bb::system::CardDoneMessage&)));
    

    In the slot of pooling:

    void ApplicationUI::pooled(const bb::system::CardDoneMessage& doneMessage) {
        Q_UNUSED(doneMessage); // Avoid a compiler warning
    
        bb::Application::instance()->quit();
    }
    

    In applicationui.hpp:

    private Q_SLOTS:
        /**
        * This slot is triggered when a card is chosen to be pooled by the system after it is closed. The card should clear it's UI
        * and states so that it is ready for the next invocation.
        */
        void pooled(const bb::system::CardDoneMessage&);
    
  • How to finalize a dvd?

    I recently burned movies on a dvd + r (which is the right type for my burner).  The movies play fine on my computer, but when I try to finalize through roxio it just keeps telling me to insert a write once dvd and it won't finalize for I can't play it on my TV.  Any ideas?  When I eject the dvd, it closes the session correctly.

    Hi larzzyboy and John.

    I read the explanation of the problem and I've been OutSite with the same thing myself. (DivX/XviD compatible) DVD player has not play recognized the DVD I burned just copy of Vista that closes only the sessiion and not the DVD.
    This question was not answered, is there a way to close the DVD (not the session) for devices other than computers can read the contents of the DVD? Is it possible at all without any third-party application? I think that if the DVD is full there will be done a DVD colsure, but what are the options for a no complete closure of DVD?

    =================================
    I am not convinced that the completion of the DVD is your difficulty
    but here is an article that explains how do...

    Windows Vista-
    Close or finalize a CD or DVD

    It may be a problem of confusion and I think that
    Since you say you used copy and paste to transfer your
    files on the DVD that you are using the Live File Format
    which may cause compatibility issues with the
    free permanent DVD player.

    If your DivX/Xvid videos and your player is DivX.
    Compatible XviD... it may be worth trying to follow the
    instructions in the following article to create a Data
    DVD. (if not... you will need to create a video DVD)

    Windows Vista-
    Burn a CD or DVD
    http://windowshelp.Microsoft.com/Windows/en-us/help/b47eb51a-ea6d-4d97-97b0-2d07a59316981033.mspx
    (Follow the instructions under the heading: "to burn a disc using the ISO image format")

    Here's another useful link:

    Windows Vista burning disc:
    Frequently asked questions
    http://windowshelp.Microsoft.com/Windows/en-us/help/2fa35b0d-B280-4589-9805-55e753888f5c1033.mspx

    John Inzer - MS - MVP - digital media experience

  • My laptop connects to the network but has no access to the internet.

    Another 169.254.x.x problem...

    I watched a lot of discussions about this problem and I tried methods in them, but still no go.

    Laptop Toshiba Satellite P300-061 / SP 2 / Vista Home x 64

    I've been connected wireless with my laptop and my desktop (with an adapter) with no problems at this cottage for about 3 to 4 days.
    Last night, I turned off the ability to laptops to detect the networks with the small button on the side, as I sometimes do.

    I turn it back on today and the laptop detects the network, but it doesn't connect to the internet. If I have limited connectivity.
    I restarted approximately 3 - 4 times and the laptop doesn't always connect. I am currently connected wirelessly on this network with my office and it works fine so that indicates that it is related to the laptop and not the router.  At first, I thought it might be a hardware problem, the laptop detects the network in the list, but it also detects the surrounding networks, which means that the wireless card works.

    ---

    Things I've tried so far.

    1 netsh winsock reset / netsh int ipv4 reset
    2 ipconfig / renew & enough & / flushdns & / registerdns
    3 Rename the connection
    4 restart / complete closure
    5. deletion of the network in the list and return the password
    6 disabling ipv6
    7 try to put the news in ipv4 manually, even though I'm not sure I did it correctly
    8 turn off the firewall
    9 uninstalling the wireless card and reboot
    10. system restore

    I'm really in the ideas and I would appreciate help, maybe I'm not the steps in the correct order, or something.
    I tried my best to search the net for a solution but they do not seem to work, and I'm really in ideas.

    Thank you for taking the time to read my thread and to help me.
    -John

    Edit: I would also add that it gives me the IP 169.254.x.x over any wireless network, I connect to.

    Hi modsiw and VioletStar,.

    You guys might already made with Gloria but give it another go on your system

    Clear ARP table

    Use the NetShell (netsh) command to erase, delete, or refresh the cache of the ARP (Address Resolution) protocol using the following steps.

    1. Click the Start button.
    2. Click the command run and type Cmd in the box text run, and then press ENTER. For Windows Vista, type Cmd in start search and press Ctrl-Shift-Enter keyboard shortcut
      to force the administrator privileges. Enter the Administrator user ID and password and allow any request for authorization when you are prompted.
    3. In the command prompt window, type the following command, and then press ENTER.
      netsh interface ip delete arpcache

    The command works in Windows Vista, Windows XP and Windows 2003.

    RESET TCP/IP ATTACH IT TO THE TOOL

    http://support.Microsoft.com/kb/299357

    REPAIR WINSOCK RESET TOOL

    http://support.Microsoft.com/kb/811259

    Let us know if this helps,

    Kevin
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • n011tu power button issue

    Hi, I bought a computer laptop n011TU yesterday. I found that when I stop the laptop, the power button is not down. Help, please... Thanks, Saha charrier

    Chandan Hi, sorry to hear that you are having problems with your computer.  If you do a full closed, the unit should be turned off completely when the correct closing is complete.  If you use Windows 7, the right way to stop him is the following.  Click Start, and then click stop. The computer shuts down and all the lights will turn off when the unit is finished with the closure. If you use Windows 8 (8.1), the process is similar but not exact. The process will be as follows.

    1. Move your mouse to the lower left corner of the screen and right click or press the Windows logo key + X on your keyboard.
  • Impossible to update 12.4.1

    I tried to upgrade to 12.4.0.119 12.4.1 days now without success.

    I tried to do it from the App Store, as well as through upgrade of iTunes itself.

    All the ideas/guides/help appreciated please!

    Please ignore previous as issue is now resolved - reboot and complete closure sorted.

  • "No reagent" receive when closing a tab.

    I already did some troubleshooting as browser was slow. I have reset the defaults and most operations are best. However, when a TAB is closed the screen turns white and title bar displays "no answer." Clicking X a couple of times, there is complete closure. Is there something unique about this operation which don't have no other crashes? Thank you very much.

    Start Firefox in Safe Mode to check if one of the extensions (Firefox/Firefox/tools > Modules > Extensions) or if hardware acceleration is the cause of the problem (switch to the DEFAULT theme: Firefox/Firefox/tools > Modules > appearance).

    • Do NOT click on the reset button on the startup window Mode without failure.

    You can check for problems with the sessionstore.js and sessionstore.bak files in the profile folder of Firefox that store session data.

    Delete the sessionstore.js file possible sessionstore-# .js files with a number and sessionstore.bak in the Firefox profile folder.

    Delete sessionstore.js will cause App Tabs and groups of tabs open and closed tabs (back) to get lost and you will have to re-create them (take note or bookmarks if possible).

  • Access the page Add-ons is defective for https

    Since a recent update of Firefox whenever I use the Google search provider in the search bar that fails because it uses the https protocol. I removed the Google search engine and tried to re - install it but when I click on the link "Get more search engines" Firefox attempts to connect to addons.mozilla.org again with https if it fails. It seems that a few recent update has passed many sites to https causing it to fail. This update has become the best browser that I have a completely unusable. Correct this TOP PRIORITY!

    The fixed!
    Our I.T. Department implemented WebSense and the root certificate is not automatically installed in Firefox. Import manually resolved the problem.

  • Download bar won't go away

    Hello

    I encounter this problem in the previous version of Mac OS X. After my download is complete, the download bar under the folder located in the launch area download dismiss himself as shown in my picture as an attachment. I need to reset my dashboard to clean.

    Hi yqchen82,

    If I understand your question, you want to know why the State Bar to your download folder does not disappear when the download is complete, is that correct?  What happens in OS X El Capitan and earlier OS X Yosemite.

    First of all, check if you have downloads that have not completed and temporarily disable automatic downloads if you have your system set up in this way.

    Resume interrupted iTunes Store downloads

    Turn on automatic downloads   (The title of the article says to turn on automatic updates, but I mean that you turn them off.

    Then I would suggest is to start your computer in Mode safe, download a file and see if the icon disappears.  If this is the case, restart your computer and try again.   If it is not the case, create a new user account and test a download using this account.

    Try safe mode if your Mac does not end commissioning

    Start in safe mode

    Follow these steps to start in safe mode.

    1. Start or restart your Mac.
    2. As soon as you hear the startup tone, hold down the SHIFT key.
    3. Release the SHIFT key when you see the logo Apple appears on the screen.

    After the Apple logo appears, this may take longer than usual to reach the login screen or your office. This is because your Mac performs a check of directory of your drive to boot in safe mode.

    To leave safe mode, restart your computer without pressing any keys during startup.

    Because what happens in multiple operating systems, the problem may be with your user account.  Here's how to test:

    How to test a question in another user on your Mac account

    Take care

  • How do I enter the BIOS in Satellite C50-A006

    Hello!

    I wanted to get into the BIOS to select the boot sequence in Satellite C50-A006 running with Win8, but I was unsuccessful. I tried pressing F2, F8, F12, ESC and DEL but no luck. Also tried Googling, also no luck.
    Help, please.

    Thank you!

    Hello

    As a first step you must perform complete closure. After doing this, you can start the machine and enter the BIOS settings.
    How to proceed to a complete stop, you can read on - http://aps2.toshiba-tro.de/kb0/TSB2B03EY0002R01.htm

    Try it please.

  • Satellite P10-304-DVD-ROM/CD-RW questions!

    Hello world

    I own one of the original computers Satellite P10-304, which has a DVD-ROM/CD-RW combo drive. For these last months, we have one or two problems with that. It was a little skittish in which CD it reads, but in the last days he almost completely stopped read correctly (audio/data) CD / DVDs. He doesn't seem to know they are there. However, the Player opens and runs well, as if it were playing the CD, but nothing happens on the PC.

    Curiously, I then looked on the list of the system, and the DVD-ROM/CD-RW driver had an excalamation mark. Even more curiously, the pilot was called TOSIICA! DWD something or other, when I'm sure it should have been DVD TOSHIBA etc.etc. Following the instructions, I uninstalled and then tried to reinstall, but it does not appear now when I try to add hardware.

    Confusing.

    I would be very grateful if anyone has any suggestions?

    See you soon,.

    Ian.

    Hello

    It looks like a car damage registry entry.
    But that is only my suggestion. The other possibility is broken (lens calibration problem) by car.
    You say that you have already removed the drive from the Device Manager, but the peut t OS recognizes the drive again. Well, in this case one of the possibilities is to use the System Restore tool or retrieve the device with the recovery CD.
    But if the drive is broken recovery procedure doesn t help. In this case, only the replacement of the drive can solve this problem.

  • Satellite Z930-130-how to REALLY turn off?

    Hi all

    Also funny that my question may sound... it is really serious!
    I have big problems in the course of the life of the battery (not so much a single charge, but affecting the "life" of the laptop itself!) because it seems even to be a way to disable COMPLETELY this laptop! It will be as a joke for a laptop of advertising with a 'eco' label that is supposed to help reduce the waste of natural resources (which was an important part of my purchase decision).

    When I put the laptop Hibernate or turn it off by long-pressing the 'Power' button, battery mode indicating LEDS etc are always on, the battery is slightly drained even when the laptop is turned off. While of course LED will certainly not use a lot of power, it means that the next time I plug it into my computer, + a new charging cycle is initiated + that could have been avoided without it. With a battery usually survive 1000 charge cycles, which will force me to buy a new battery (by the way: what a shame how "yesterday" and that the battery is built-in and not replaceable by the buyer!) within 2 years if I plug off a few times every day.

    Alltogether that sounds a lot like "planned obsolescence" and I'm annoyed by the mere thought of support something like that. Basically, I'm very happy with the Z930, so, I'm more frustrated by this completely unnecessary battery drain. No idea how to activate these LED to the wide and really turn off computer? Or an update of the BIOS just the thing?

    BTW, I would be also grateful for advice on how to put pressure on the softer touchpad mouse buttons and easy - on my laptop, they have to be hurry * very * hard.

    My model: Toshiba Satellite Z930 - 130 33.8 cm (13.3 Zoll) Ultrabook (Intel Core i7 3667U, 2 GHz, 4 GB RAM, 256 GB SSD, Intel HD 4000, win 8)

    Thank you, r.

    If you write about complete closure that you can find the answer on follow Toshiba document - http://aps2.toshiba-tro.de/kb0/TSB2B03EY0002R01.htm

  • Satellite C55-A-1N2 - Windows is broken and without access to the repair option

    Hello

    One of my friends had a Satellite C55-A-1N2 nine November 2013 with windows 8.1.
    The serial number is: yd344983s

    Initially, there was a problem with wifi.
    I found a lot of adware...

    I have uninstall most of them by hand and clean everything with adwcleaner.
    The laptop works very well, I cut the DNS client service and add anti-pupsadware in the hosts file to prevent any new installation of adware.

    Everything was ok and give again to a friend.
    But the new commissioning, windows was slow, unable to connect wifi, enter in the config panel, do anything actually.

    I tried according to manual, press F8 and power, but who turns just to log on windows.
    I also tried F12 and tried to use the CD of windows 7 without success.

    You have ideas of what I can do?
    This looks pretty bad.
    Thank you.

    Mickael
    France.

    If you want to restart the laptop and use the repair options or recovery, you must perform the complete closure. How to do that you can read on http://aps2.toshiba-tro.de/kb0/TSB2B03EY0002R01.htm
    Reboot the laptop and if you want to use the repair options or recovery check it please the instructions on http://aps2.toshiba-tro.de/kb0/TSB2A03ES0000R01.htm

    PLESE NOTE: do not do some experiences before you have created a recovery media. Use the preinstalled recovery media creator tool and create recovery DVDs or USB.
    If there is a problem, you can use this recovery media to reinstall the original version of Windows.

  • How to get into BIOS and boot on Satellite C50-A-1GZ menu?

    Hello

    in other words, how to start the BIOS and boot my Toshiba C50-A-1GZ menu?
    Thank you

    Hello

    As a first step you must perform complete closure. How to do that you can read on http://aps2.toshiba-tro.de/kb0/TSB2B03EY0002R01.htm

    Restart your computer and press F12. There you should find the configuration options for the BIOS settings.

  • Satellite L650 - Fan not kick (work) after the fashion 'sleep'

    Hi all

    The fan does not work when you restart the standby mode, but only after complete closure.
    What causes this and how can I solve this problem?
    Toshiba L650 - 170 system unit

    Thank you!
    Luke

    A number of questions:
    Have you noticed the fan operating with the preinstalled Toshiba system problem?
    Have you noticed this first day of purchase?

    The Satellite A660 is a little old and already abandoned the model and therefore, it would be interesting to know if something has changed in the past

    Anyway, there are different modes of sleep (sleep is divided into four States, S1 to S4)

    S1, to suspend him (POS): all processor caches are flushed, and the CPU stops the execution of the instructions. The power of the CPU and RAM is maintained. Devices that do not indicate that they must remain lit, can be turned off.

    S2: CPU power off. Dirty cache is emptied to the RAM.

    S3, commonly known as secondary, sleep or Suspend to RAM (STR): RAM remains powered.

    S4, hibernation or Suspend to Disk: all content of main memory is stored in a nonvolatile memory such as a hard drive and is turned off.

    Using the Powercfg command you will be able to check this "standby" and might it change too.
    Details here: http://en.wikipedia.org/wiki/Powercfg
    It would be interesting to know how "sleep" you use exactly and if the fan would be using a "sleep" mode

Maybe you are looking for