software you can take with you

Connect failed when receiver reject downloading data - 32feet.NET 3.0

Last post 03-21-2011 6:58 PM by alanjmcf. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 03-20-2011 5:46 PM

    • m1chu
    • Not Ranked
    • Joined on 03-20-2011
    • Posts 2

    Connect failed when receiver reject downloading data - 32feet.NET 3.0

    Hello.

    I have some problem with uploading the data to any device. It's what i'm doing.

    I'm sending one file by using Microsoft stack. The receiver is mobile device - Nokia. The first message in mobile phone is something like "Receive data from NAME_OF_SENDER?". When i choose Accept everything is ok. When i choose Reject or i don't make any choose before timeout attained client application stopped by exception:

    "An unhandled exception of type 'System.Net.WebException' occurred in InTheHand.Net.Personal.dll

    Additional information: Connect failed."

    For this example I'm trying to send text file, smaller than 200 bytes.

    This is my sending part of code:

                InTheHand.Net.BluetoothAddress address;
                System.Uri uri;
                ObexWebRequest request;
                ObexWebResponse response;
                for (ushort i = 0; i < clients_indexes.Length; ++i)
                {
                    try {
                        address = this.clients_array[clients_indexesIdea].DeviceAddress;
                        uri = new Uri("obex://" + address.ToString() + "/" + filename);

                        request = new ObexWebRequest(uri);
                        request.Timeout = 5000;
                        request.ReadFile(fullpath);

                        response = (ObexWebResponse)request.GetResponse();
                        if (response != null)
                            response.Close();               
                    }
                    catch (System.Net.WebException ex)
                    {
                        return false;
                    }
                }

    I have done some tests with much older version of 32feet (1.6) and this problem doesn't exist. I know, that in InTheHand.Net.Personal.dll is method throwing exception with value "Connect failed". Bot how can I catch it and continue sending file to next devices by using loop from above code? Like you see mine, above method doesn't work.

    Thanks for any suggestions and code samples.

  • 03-21-2011 7:09 AM In reply to

    Re: Connect failed when receiver reject downloading data - 32feet.NET 3.0

    We changed ObexWebRequest/Response to use exceptions rather than error codes at version 2.2.[1]

    I can't see why you code isn't catching the exception, it catches WebException and that's the exception that you are seeing.  Is there code elsewhere in your app doing OBEX?

    Presumably you are running this in the debbugger.  Set it to stop on exceptions (Debug->Exceptions: CLR Exceptions = Thrown) and see where it is occuring.

     

    [1] http://32feet.codeplex.com/workitem/8453

  • 03-21-2011 9:17 AM In reply to

    • m1chu
    • Not Ranked
    • Joined on 03-20-2011
    • Posts 2

    Re: Connect failed when receiver reject downloading data - 32feet.NET 3.0

    Thanks for reply.

    Going by your hint I set the debbugger to stop on CLR exceptions. Now I see exception like this:

    "A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll

    Additional information: A socket operation failed because the destination host was down"

    Mobile phone has bluetooth connection on and is visible for everyone.

    Exception occured on: "response = (ObexWebResponse)request.GetResponse();"

    I have exchange InTheHand.Net.Personal.dll by compiling sources from http://32feet.codeplex.com/SourceControl/list/changesets (86308) and done some more tests. Now the exception is occuring in SocketBluetoothClient.cs, in method Connect(BluetoothEndPoint remoteEp) on underlined line:

            public virtual void Connect(BluetoothEndPoint remoteEP)
            {
                EnsureNotDisposed();
                if (remoteEP == null) {
                    throw new ArgumentNullException("remoteEP");
                }

                Connect_StartAuthenticator(remoteEP);
                try {
                    var connEP = PrepareConnectEndPoint(remoteEP);
                    clientSocket.Connect(connEP);
                    active = true;
                } finally {
                    Connect_StopAuthenticator();
                }
            }

  • 03-21-2011 6:58 PM In reply to

    Re: Connect failed when receiver reject downloading data - 32feet.NET 3.0

    So now look at the debugger's "Call Stack" window and make sure that where you call this from your code is inside your try/catch block.

    If you now hit Continue (F5) it'll be thrown there and then caught and changed into the WebException, and if you hit F5 again thrown from there...

Page 1 of 1 (4 items)
Copyright © 2001-2013 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy. OrcsWeb's Windows Cloud Server Hosting