.NET Components for Mobility

Error 10061 connecting to printer

Last post 03-07-2007 11:34 AM by AfG. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 02-21-2007 5:19 PM

    • AfG
    • Not Ranked
    • Joined on 02-21-2007
    • Enfield, UK
    • Posts 0

    Error 10061 connecting to printer

    We have an application written in Vb.net running on a Psion WorkaboutPro handheld running under Windows CE4.2. The application issues tourist tickets using a Zebra cameo 2 bluetooth printer. We have just found the InTheHand library and I have set up a small test application based on the code in one of the samples. This finds available devices using the DiscoverDevices method and that works fine. However when we try to call the Connect method we get a socket exception 10061. There are no inner exceptions found. Having had a look on the forums this seems to be caused in some cases by firewalls blocking ports but these devices are not running firewalls.

     Our main application currently uses OpenNetCf's serial port driver to talk to the printer which is paired with the Psion. This makes contact and sends data to the printer. That connection is working OK. When the initial test system failed I wondered if the existing pairing was the problem so I disconnected the pairing on the Psion and rebooted the printer software to clear the pairing from that end. But this made no difference. The InTheHand connection still failed with error 10061.

    Here is the code being run It is adapted from the sample code so the service name is

     

        Private ServiceName As New Guid("{E075D486-E23D-4887-8AF5-DAA1F6A5B172}")
     ...

                 Do
                    Try
                        If client Is Nothing Then
                            client = New BluetoothClient
                        End If
                        client.Connect(New BluetoothEndPoint(CType(cboDevices.SelectedItem, BluetoothDeviceInfo).DeviceAddress, ServiceName))

                    Catch se As SocketException
                        Me.txtMessages.Text &= ControlChars.CrLf & "Fail " & se.Message
                        If (CurrentTries >= NumRetries) Then
                            Throw se
                        End If
                        Dim xx As IO.StreamWriter = IO.File.AppendText("BTConnectionErrors.txt")
                        xx.WriteLine("**" & Now.ToString)
                        xx.WriteLine(se.Message)
                        xx.WriteLine("Native error " & se.NativeErrorCode.ToString)
                        xx.WriteLine("Error code " & se.ErrorCode.ToString)
                        If Not se.InnerException Is Nothing Then
                            Dim yy As Exception = se.InnerException
                            While Not yy Is Nothing
                                xx.WriteLine("From: " & yy.ToString)
                                yy = yy.InnerException
                            End While
                        Else
                            xx.WriteLine("No inner exceptions")
                        End If
                        xx.Close()
                    End Try
                    CurrentTries = CurrentTries + 1

                Loop While CurrentTries < NumRetries


     Can anyone tell me what else I should be looking at or doing please.

    In case anyone is wondering, we are looking for alternative drivers for the printer because the Psion has a Bluetooth 1.1 implementation which cannot be upgraded and in our operating environment in Central London we have a very crowded and hostile telecomms environment and the OpenNetCf implementation keeps losing connection and having to retry several times before it re-connects. So we are interested to see if using the IntheHand library had the same problem.

     

    Thanks



     

    Andrew
  • 02-22-2007 2:29 PM In reply to

    Re: Error 10061 connecting to printer

    A device can support various services, listening on various endpoints, like with TCP/IP port 80 for HTTP, 25 for SMTP etc.  In Bluetooth a service is identified by a UUID, and the one you're using there is a custom one use in the chat sample.  Assuming the printers listen on the SerialPortProfile, then substitute it with InTheHand.Net.Bluetooth.BluetoothService.SerialPort (e.g. Dim ServiceName As Guid = InTheHand.Net.Bluetooth.BluetoothService.SerialPort) see http://32feet.net/library/InTheHand.Net.Bluetooth.BluetoothServiceFields.html

    It will be interesting to see if you see different behaviour...

    Alan J. McFarlane
    http://www.alanjmcf.me.uk/
    Please follow-up in the newsgroup for the benefit of all.
    Have I helped? Consider visiting my Amazon wishlist, see my homepage.
  • 02-23-2007 11:03 AM In reply to

    • AfG
    • Not Ranked
    • Joined on 02-21-2007
    • Enfield, UK
    • Posts 0

    Re: Error 10061 connecting to printer

    Thanks for the fast response. What you said made sense. There is a lot of groping around using half knowledge when getting to grips with new technologies and I was not at all clear what the service name was doing.

     I tried substituting the serial port service guid as you suggested. I am still getting an error when I try to connect but it has changed. The error now comes from System.net.sockets.socket and is an ObjectDisposed exception. I trapped the error and checked for inner exceptions but there are none.

     I am not calling the BluetoothClient's Dispose method explicitly so I must be doing something to implicitly call it. The only other call I make to it is to DiscoverDevices which is working fine. The printer is currently known to the Psion it was paired with it but I switched the pairing off to see if it made a difference and it didn't. When I try to connect the Bluetooth access light on the printer lights up so they do seem to be talking, if not the same language.

     Do you have any further thoughts on what is happening or what i might try. Any help would be appreciated.

     
    Thanks

    Andrew
     

    Andrew
  • 02-26-2007 9:05 PM In reply to

    Re: Error 10061 connecting to printer

    Sounds odd.  Either Close or Dispose would need to be called, the latter perhaps being called by a "using" block.  Or no references to the client and thus Finalize being called, but you're blocking on a call to Connect.  Hmm?!  Are you calling the constuctor, DiscoverDevices, and/or Connect from different threads?  Are you calling Connect twice per chance?  Or, it shouldn't happen, but maybe the connect is failing and somehow transmogrifying into that exception.  It shouldnt happen anyway... :-)

    Alan J. McFarlane
    http://www.alanjmcf.me.uk/
    Please follow-up in the newsgroup for the benefit of all.
    Have I helped? Consider visiting my Amazon wishlist, see my homepage.
  • 02-28-2007 11:52 AM In reply to

    Re: Error 10061 connecting to printer

    Is there any chance that another device is trying to connect to the printer at the same time. 10061 can occur if the device is busy serving an existing connection. Also do you have any control over the discoverability settings of the printer, if the printer responds to a device lookup it will be unavailable for other connections at that time.

    Peter

    Peter Foot
    Microsoft Device Application Development MVP
    www.peterfoot.net | www.inthehand.com
  • 03-07-2007 11:34 AM In reply to

    • AfG
    • Not Ranked
    • Joined on 02-21-2007
    • Enfield, UK
    • Posts 0

    Re: Error 10061 connecting to printer

    Thanks very much for your comments. I'm sorry I have not replied before. We are moving house and have to do it in a hurry due to a buyer delaying the sale and then having to rush it through. As a result I have not been able to work on the system for the past week. I hope yo be set up in the new house next week and will be following up some of your suggestions but my broadband will not be on for a further week so I don't know when i will be able to post results.

     However your comments and those of Alan are much appreciated

    Regards

     
    Andrew
     

    Andrew
Page 1 of 1 (6 items)
Copyright © 2001-2008 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy.