ArgumentError: Error #2082: Connect failed because the object is already connected.

ArgumentError: Error #2082: Connect failed because the object is already connected.

Cause:
To quote Seth Hodgson at Adobe:
That should be an intermittent problem. If the Flash Player is force quite (due to a crash, force quiting your browser in Windows Task Manager, or possibly stopping a debug session in FlexBuilder) a LocalConnection may be orphaned in shared memory. When this happens, if you restart your app and it attempts to reconnect its LocalConnection it will fail.

Try making sure all Player instances are shut down which will clean up the orphaned LocalConnection and worst case, restart. There’s a bug logged for this and you won’t hit it during normal operation.

Restarting the computer fixed this problem. Some have stated restarting the browser fixed it.

UPDATE!
As reported by rock star reporter and coder Andriy Panas, Peter DeHaan from Adobe, has suggested to wrap up the call to _lcFromFlash.connect routine into try…catch.. block as mentioned in this thread http://www.nabble.com/Workaround-for-Error–2082-tf4209682.html#a11974844.

Please reply in the comments below if this helped you or not.

This entry was posted in Flex. Bookmark the permalink.

20 Responses to ArgumentError: Error #2082: Connect failed because the object is already connected.

  1. Coder Dude says:

    I’ve seen this problem sporadically but on a fairly regular basis, and I know that it’s due to Flash crashing and something being left behind. It seems having the problem in one browser also causes Flash to malfunction in the other browser (IE / Firefox). Yes rebooting the computer fixes the problem. But:

    1) Having this happen at all is unacceptable, esp. since the idea of Flash is it runs everywhere with no problems
    2) Having to reboot the computer to deal with this is really bad
    3) This falls clearly into the bug category and needs to be fixed

    So, I’ve disabled history management entirely for the app I’ve deployed and have seen no such problems since.

  2. Aral Balkan says:

    I’ve just run into this after having to force quit Firefox and Safari because of a Flex-app-induced hanging :) Going to try the restart. Thanks for documenting it.

  3. Aral Balkan says:

    A quick update: Restarting fixed the problem over here too (OS X; Safari/Firefox).

  4. I’m using Flash Authoring to create content so I’m not seeing the exact error message that you indicate, but I am seeing the same behavior in my SWFs that talk via LocalConnection. They’ll work fine for a while and then they’ll stop being able to communicate via LocalConnection at all. Hibernating and waking up my machine seems to make this happen more often. And it does require a complete reboot, just restarting the browser (or switching to a different browser) doesn’t help. Windows XP, Firefox 2/IE7. It’s a drag, now I’m trying to figure out if I can just remove LocalConnection from my app altogether.

  5. Along with closing any open browsers, you also need to close any other applications that might have the Flash player running, which includes Yahoo Messenger.

  6. Patrickb says:

    Wow, restarting and closing all open apps doesn’t remove the problem for me. I continue to get the “Error #2082: Connect failed because the object is already connected” message even with nothing running and the computer freshly restarted. Besides this, asking clients to make sure everything is closed just so I can use LocalConnection isn’t really a viable solution, is it? One of the things I noticed, which is really odd, is that the LocalConnection.connect method returns void rather than true or false. This is further accentuated when you try to assign the result of this operation to a Boolean typed variable where an extra error is thrown because LocalConnection returns void rather than a valid true or false. So far, regardless of the connection name, software running, or restart status of my computer, LocalConnection has failed to connect. I think this is a bug that Adobe will need to address because it clearly isn’t working as advertised.

  7. Judah says:

    Patrickb – What player version are you using? I would post it here http://bugs.adobe.com/flex/.

  8. Jai says:

    Hi,
    Did anybody figured out a solution to this. I am also facing the same problem.

    Interesting It works fine on Firefox 2.0, but fails on IE 7.

    I am using Flex stress testing framework for testing an application that uses Remote object to connect to a java class, which in-turn connects to a MySQL database to retrieve somewhere around 20,000 records. When I run a single instance of the application, it works fine. If I try to open multiple instances of the application (for stress testing purpose), some of the instances fail to initialize and throw the following error (even before I trigger the code to retrieve the data from remote object):

    ArgumentError: Error #2082: Connect failed because the object is already connected.
    at flash.net::LocalConnection/connect()
    at mx.managers::HistoryManagerImpl$iinit()
    at mx.managers::HistoryManagerImpl$/getInstance()
    at mx.core::Singleton$/getInstance()
    at mx.managers::HistoryManager$/get ::impl()
    at mx.managers::HistoryManager$/register()
    at mx.containers::ViewStack/mx.containers:ViewStack::commitProperties()
    at mx.core::UIComponent/validateProperties()
    at mx.managers::LayoutManager/::validateProperties()
    at mx.managers::LayoutManager/::doPhasedInstantiation()
    at Function/http://adobe.com/AS3/2006/builtin::apply()
    at mx.core::UIComponent/::callLaterDispatcher2()
    at mx.core::UIComponent/::callLaterDispatcher()

    Thanks

  9. Patrickb says:

    Hi Judah,

    I have player version 9.0.47.0 and am using Flash CS 3 for exports. I am using LocalConnection somewhat uniquely so I tried creating a simple (5-line) class with a LocalConnection connect only. I restarted the computer and made sure nothing else was running (like local web server etc.) just to make sure ports weren’t being taken up. I ran the thing and it failed right off the top. I really can’t see any reason for this to be failing under ideal conditions…and besides, having to restart a computer isn’t really a great solution anyways (if it worked, which in my case it doesn’t). Whatever’s happened to LocalConection in Flash 9, it has some serious flaws. I have yet to successfully use it, even in the simplest of ways. Any one else have any suggestions because I’m completely out of ideas!

    Thanks,
    Patrick

  10. JabbyPanda says:

    I found to be good enough solution for this problem #2082 to wrap up the call to _lcFromFlash.connect routine into try…catch.. block as it was suggested here by Peter DeHaan from Adobe: http://www.nabble.com/Workaround-for-Error–2082-tf4209682.html#a11974844

  11. John Grden says:

    I reported this bug in flash 8 beta. It happens when you make a call to another swf and are expecting a response. When the other swf doesn’t respond, you try and close the one that initiated the original call.

    When that happens, you get this behavior. I experienced it when I was updating Xray and running tests on pausing the player with an LC call, which doesn’t work ;)

    Macromedia filed it as a bug, to be resolved in later revisions of the player.

    http://labs.blitzagency.com/?p=33 – here’s my original post on it. I guess it’s still there ;)

    I didn’t have to reboot, all I had to do was close everything that used the flash player – MSN, gtalk, IE, FF you name it. I might as well have rebooted after shutting all of that down.

  12. Patrickb says:

    Hi guys,

    Any news on this issue? I simply can’t get LocalConnection to work at all. The “try..catch” block doesn’t work either. The exception is never caught by my code (the error still pops up but a trace message I put into the “catch” block doesn’t show up). There is something seriously wrong here. I know that the connection I’m trying doesn’t exist (fresh reboot). I’m not running anything that could be using Flash other than the Flash IDE. My class literally looks like this:

    package com.bnm {

    public class myClass {

    import flash.external.*;
    import flash.net.*;
    import flash.system.*;

    public function myClass() {
    this.makeConnection();
    }

    public function makeConnection() {
    var lc=new LocalConnection();
    lc.connect(“SomeoutrageousNamethatdoesntexist”);
    }
    }

    …and this fails. There is nothing else happening in the class besides this. In the constructor this does the same thing, in this function it does the same thing. I’m really stumped here. I don’t see what I’m doing wrong and Adobe hasn’t made a mention of it. It’s been 3 months and going and I simply haven’t been able to get this to work at all :(

  13. Daniel says:

    To solve the “Connect failed because the object is already connected” this is the way to go:

    Flex ———————- Flash
    1. generate unique key
    2. connect with generic key —- connect with generic key
    3. send unique key ———-—–> key received
    4. close connection ———- close connection
    5. connect with unique key —- connect with received key

  14. Jahiro says:

    @Daniel – Thanks for the idea. Simple strategy that works like a charm.

    I recommend his approach if you need to open up multiple pages, each with a local connection to the same SWF.

  15. elaine! says:

    Your Update comment helped a ton. I was using gskinner’s SWFBridge package to get an AS2 doc and its AS3 parent talking to each other, but I would get the “object is already connected” error if the site was opened in two browsers or two browser tabs at the same time (and occasionally when refreshing the browser). Adding one more try/catch and changing the e: to e:* worked like a charm.

  16. Saad says:

    This error was appearing whenever I refresh page.

    I had one master banner with 2 child banners connected via local object

    In the master I pushed the first frame (with actions related to LocalConnection) by about 5 frames.

    Basically Flash player was too slow to close the connection object on unload/refresh, a bit delay in the beginning solved the problem.

  17. qtpeng2009 says:

    Still having this issue even about 7 years passed by. I cannot believe it.

Leave a Reply

Your email address will not be published. Required fields are marked *

Wrap your code before posting! Click the links below:

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="">