java.io.IOException: Service discovery failed

IanMc

Well-Known Member
Licensed User
Longtime User
When you create a virtual serial Com port for bluetooth as an incoming port on the PC you can discover it from your Basic4android app but it would seem that if it is not in use ie: if it is not bound by something like a terminal application then when you try to connect to it you get the error:

java.io.IOException: Service discovery failed

And Amazon reject your app :sign0148:

Is there any way to test for this using Try Catch ?
Then I could display my own error message.

Amazon's helpful rejection email states the error as:

"BTInterfaceFreeTrialBETA Error Connecting: java.io.IOException: read Failed, Socket might closed read ret:-1" appears.


OS/Device(s)/Form Factor: 2.3.3/HTC Desire HD A9191/Phone.
4.2.1/Nexus 7/Tablet.
4.1/Samsung Galaxy Nexus/Phone.
 

Victor Pavlov

Member
Licensed User
Longtime User
One more problem:

"java.io.IOException: Transport endpoint is not connected"

In Printer.Flush after Successful connection.

B4X:
Private Sub BTPort_Connected (Success As Boolean)
Dim s As String
Dim Block As Int = 1024

If Success Then
        Printer.Initialize2(BTPort.OutputStream, "windows-1251")
      
        Do While Contents.Length > 0
            If Contents.Length > Block Then
                s = Contents.SubString2(0, Block)
                Contents = Contents.SubString(Block)
            Else
                s = Contents
                Contents = ""
            End If
      
            Printer.Write(s)
            Printer.Flush
          
            Sleep
        Loop
      
        Printer.Close
        BTPort.Disconnect
    Else
 
Upvote 0

Isa Paine

Member
Licensed User
Longtime User
I also get the error "Error connecting: java.io.IOException: read failed, socket might closed (sic) or timeout, read ret: -1" on the
B4X:
 serial1.Connect(connectedDevice.Mac)
line of the Bluetooth Example program. Then when Serial1_Connected fires, Success = false. Why am I getting this problem and How do I correct this for it?

My PC is discovered, I select it from the prompt, but I get the above described error.

I am trying to connect from a Samsung Galaxy S5 to my PC via a Bluetooth 4.0 Dual Mirco USB Adapter.
 
Upvote 0
Top