2013-02-04 4 views
0

블루투스 채팅을 기반으로 안드로이드 블루투스 게임을 개발 중입니다. 잘 작동하는 것처럼 보이지만 매 5 - 10 건마다 응용 프로그램 충돌이 발생합니다. 이는 버퍼가 오버플로 된 것 같습니다. 한 대의 장치를 서버로 사용하고 다른 하나의 장치는 클라이언트로 사용합니다.블루투스 채팅 안드로이드 연결/발견 버그

때때로
02-04 21:15:11.381: DEBUG/BluetoothService(2322): start 
02-04 21:15:11.381: DEBUG/BluetoothService(2322): setState() 0 -> 1 
02-04 21:15:12.432: ERROR/BluetoothService(2322): Socket Type: Insecurelisten() failed 
     java.io.IOException: Bad file number 
     at android.bluetooth.BluetoothSocket.throwErrnoNative(Native Method) 
     at android.bluetooth.BluetoothAdapter.createNewRfcommSocketAndRecord(BluetoothAdapter.java:884) 
     at android.bluetooth.BluetoothAdapter.listenUsingRfcommWithServiceRecord(BluetoothAdapter.java:820) 
     at com.insomniacpro.pillows.Bluetooth.BluetoothService$AcceptThread.<init>(BluetoothService.java:312) 
     at com.insomniacpro.pillows.Bluetooth.BluetoothService.start(BluetoothService.java:132) 
     at com.insomniacpro.pillows.engine.MultiGameActivity.onResume(MultiGameActivity.java:159) 
     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1242) 
     at android.app.Activity.performResume(Activity.java:3904) 

서버 장치 (: 내 phone.It가 발생 재부팅까지 - 내가 다시 연결을 시작하지 못할 것을,

02-04 21:11:54.139: DEBUG/BluetoothService(2048): start 
02-04 21:11:54.139: DEBUG/BluetoothService(2048): setState() 0 -> 1 
02-04 21:11:54.169: DEBUG/BluetoothService(130): new handle 9 
02-04 21:11:54.179: DEBUG/BluetoothService(2048): Socket Type: InsecureBEGIN mAcceptThreadThread[Thread-47,5,main] 
02-04 21:11:55.870: ERROR/BluetoothService.cpp(130): stopDiscoveryNative: D-Bus error in StopDiscovery: org.bluez.Error.Failed (Invalid discovery session) 
02-04 21:11:55.890: DEBUG/BluetoothService(2048): connect to: 10:BF:48:E8:C1:26 
02-04 21:11:55.890: DEBUG/BluetoothService(2048): setState() 1 -> 2 
02-04 21:11:55.900: INFO/BluetoothService(2048): BEGIN mConnectThread SocketType:Insecure 
02-04 21:11:55.900: ERROR/BluetoothService.cpp(130): stopDiscoveryNative: D-Bus error in StopDiscovery: org.bluez.Error.Failed (Invalid discovery session) 
02-04 21:11:57.222: DEBUG/BluetoothService(130): updateDeviceServiceChannelCache(10:BF:48:E8:C1:26) 
02-04 21:11:57.222: DEBUG/BluetoothService(130): uuid(system): 00001105-0000-1000-8000-00805f9b34fb -1 
02-04 21:11:57.232: DEBUG/BluetoothService(130): uuid(application): fa87c0d0-afac-11de-8a39-0800200c9a66 3 
02-04 21:11:57.232: DEBUG/BluetoothService(130): Making callback for fa87c0d0-afac-11de-8a39-0800200c9a66 with result 3 
02-04 21:12:05.910: ERROR/BluetoothService.cpp(130): stopDiscoveryNative: D-Bus error in StopDiscovery: org.bluez.Error.Failed (Invalid discovery session) 
02-04 21:12:06.491: DEBUG/BluetoothService(2048): stop 
02-04 21:12:35.779: DEBUG/BluetoothService(130): Tracked app 2048 died 
02-04 21:12:35.779: DEBUG/BluetoothService(130): Removing service record 8 for pid 2048 
02-04 21:12:35.789: DEBUG/BluetoothService(130): Tracked app 2048 died 
02-04 21:12:35.789: DEBUG/BluetoothService(130): Removing service record 2 for pid 2048 
02-04 21:12:35.789: DEBUG/BluetoothService(130): Tracked app 2048 died 
02-04 21:12:35.789: DEBUG/BluetoothService(130): Removing service record 1 for pid 2048 
02-04 21:12:35.799: DEBUG/BluetoothService(130): Tracked app 2048 died 
02-04 21:12:35.799: DEBUG/BluetoothService(130): Tracked app 2048 died 
02-04 21:12:35.799: DEBUG/BluetoothService(130): Tracked app 2048 died 
02-04 21:12:35.799: DEBUG/BluetoothService(130): Removing service record 7 for pid 2048 
02-04 21:12:35.809: DEBUG/BluetoothService(130): Tracked app 2048 died 
02-04 21:12:35.809: DEBUG/BluetoothService(130): Removing service record 4 for pid 2048 
02-04 21:12:35.819: DEBUG/BluetoothService(130): Tracked app 2048 died 
02-04 21:12:35.819: DEBUG/BluetoothService(130): Removing service record 6 for pid 2048 
02-04 21:12:35.819: DEBUG/BluetoothService(130): Tracked app 2048 died 
02-04 21:12:35.819: DEBUG/BluetoothService(130): Tracked app 2048 died 
02-04 21:12:35.819: DEBUG/BluetoothService(130): Removing service record 5 for pid 2048 
02-04 21:12:35.829: DEBUG/BluetoothService(130): Tracked app 2048 died 
02-04 21:12:35.829: DEBUG/BluetoothService(130): Tracked app 2048 died 
02-04 21:12:35.829: DEBUG/BluetoothService(130): Removing service record 3 for pid 2048 
02-04 21:12:35.829: DEBUG/BluetoothService(130): Tracked app 2048 died 
02-04 21:12:35.829: DEBUG/BluetoothService(130): Removing service record 9 for pid 2048 
02-04 21:12:35.839: DEBUG/BluetoothService(130): Tracked app 2048 died 
02-04 21:12:35.839: DEBUG/BluetoothService(130): Tracked app 2048 died 
02-04 21:12:35.839: DEBUG/BluetoothService(130): Tracked app 2048 died 
02-04 21:12:35.839: DEBUG/BluetoothService(130): Tracked app 2048 died 

그리고 최악의 일 : 클라이언트 (HTC EVO 4G)이 추적과 충돌 Nexus 7)이 작동을 멈추게하려면 다시 부팅해야합니다. 스택 :

java.io.IOException: Error: -1 
    at android.bluetooth.BluetoothAdapter.createNewRfcommSocketAndRecord(BluetoothAdapter.java:1035) 
    at android.bluetooth.BluetoothAdapter.listenUsingRfcommWithServiceRecord(BluetoothAdapter.java:951) 
    at com.insomniacpro.pillows.Bluetooth.BluetoothService$AcceptThread.<init>(BluetoothService.java:312) 
    at com.insomniacpro.pillows.Bluetooth.BluetoothService.start(BluetoothService.java:132) 
    at com.insomniacpro.pillows.engine.MultiGameActivity.onResume(MultiGameActivity.java:159) 
    at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1185) 

Maybe BluetoothChat app doesnt closes sockets well, when connection is closed? 

어떤 도움이 유용 할 것이다!

답변

0

마지막으로 연결이 끊어 지거나 실패 할 때마다 onFinish()를 호출하는 등의 나쁜 해결책으로 끝났습니다. 내 사건에는 적절하지만 다른 사건에는 적절하지 않습니다. 그것은 저에게, BluetoothChat에있는 connectionLost() 함수가 불완전한 것 같습니다. 다른 방법으로 포트를 정리해야합니다.

+1

심지어 이런 상황에 직면 해 있습니다. 당신은 onFinish()에서 무엇을합니까? 너를 공유 할 수 있니? – Basher51

관련 문제