I use Bluecove 2.1.1 and trying to restart bluetooth service, but after closing connection and reopening I can't connect to service, I got "Connection refused" exception. I found this issue on Bluecove site? I also try to change service name(also UUID) after closing connection, but it's not help. Does anyone know workaround for it? I'm simply need to restart bluetooth service.
I am not sure if I understood your question in the way it meant to be.
I assume that you are opening a Connector and let a SessionNotifier handle OBEX connections with accecptAndOpen(ServerRequestHandler).
When a clients connects to your bluetooth service the specific methods in your ServerRequestHandler are called (onGet, onPut, ..). When the client disconnects onDisconnect is triggered. Now you need to acceptAndOpen your service again to handle future connections.
Related
I am working on developing a file system manager client that connects and do file handling with Azure file share using Java.
By referring Azure docs I could see how a connection is made with the connection string and how the file manipulation is done. But there is no such thing as a connection close step.
I wonder if for Azure, created connections automatically get closed or is the doc missing something? As far as I know, if a connection is made, that needs to be closed after the tasks related with are done.
Help me clarify this.
Considering the SDK is simply a wrapper over HTTP REST API, the moment the operation is complete (i.e. response is received), the connection automatically closes. You don't have to do anything special to close the connection.
I have a Play 2 (2.3.7) app that uses EventSource connections. Everything works fine except when I try to close the connection from the client. To do that I am using the ES.close method, but even after I disconnect Play only detects that the connection was closed (and processes the onDisconnect callback) when I send a ping to the client. Closing the connection from server side works as expected.
I tried this in Chrome/Firefox (using native implementation) and using Yaffle ES polyfill and the result is the same. Both client and server are running in a linux machine.
EDIT: After closing the connection in the browser console and inspection the network tab in dev tools it seems the connection is indeed closed by the browser. So this may be a problem of Play?
So what may be the problem here?
I am making application in j2me, i am sending data to server
but before that i want to first check that if internet is working or not (it may be from WIFI or GPRS)
Try to use getResponseCode() and getResponseMessage() methods of HttpConnection API .
There's no reliable way to determine if 'the internet is working' other than sending a request to your server. Just because you have a connection to an ISP, it doesn't mean that the ISP has a connection to the internet, or that a packet sent via that connection can reach your server.
The phone might tell you it's not connected, but if you want to know whether you can reach your server when it is connected, send a request and see what happens.
Sorry for kind of a dummy question, but I'm wondering how to work with WiFi connection via android. My application needs to transfer some data (both receiving and sending) with PC or with other android device using WiFi. How should I organize the process? I mean, how should I establish connection, then should I open a socket for data transfering, etc. Is there any way to do it without internet connection, smth like bluetooth, except wifi.p2p (which is only available for android 4.0)? Would be grateful for as detailed manual as possible.
Every network connection even if only in the local network or localhost reqieres the INTERNET permission.
Bluetooth and NFC might be an option, but I have no experiance with that.
I am developing an application which uses Bluetooth to connect to a device and send/receive data. I am doing all of my testing with a Nexus One phone.
I have never been able to establish a SPP (serial port) connection from my phone to any device. However, I have been able to connect from a device (my laptop) to my phone using a Mac equivalent of PuTTY (The only exception to this is the "Bluetooth File Transfer" app from the Marketplace seems to work, but I don't think that uses RFCOM/SPP...).
I keep seeing this message in my LogCat logs:
ERROR/BluetoothService.cpp(78): stopDiscoveryNative: D-Bus error in StopDiscovery: org.bluez.Error.Failed (Invalid discovery session)
as well as these:
java.io.IOException: Operation Canceled
java.io.IOException: Software caused connection abort
I have tried using the UUID of "00001101-0000-1000-8000-00805F9B34FB" and I have also tried using the:
Method m = device.getClass().getMethod("createRfcommSocket", new Class[] { int.class });
sock = (BluetoothSocket) m.invoke(device, Integer.valueOf(1));
method instead of device.createRfcommSocketToServiceRecord(UUID); as well--with no luck.
I am using the BluetoothChat example and variations of that code to do all of my testing...
Solutions or suggestions would be great...or even a better/less complex example of some testing code I can run on the phone, or a python script or something I can run on my computer to help debug?
Thanks! I hope this isn't a bug with the Android OS, but if it is I hope to find a workaround.
EDIT: I should also note that most devices show up as "paired, but not connected" in the Bluetooth settings.
EDIT 2: The solution seems to be simply disabling any Bluetooth listening. See my answer post for more information.
The solution, as it turns out, was to disable the server functionality of the Bluetooth service. By only using createRfcommSocketToServiceRecord and never calling listenUsingRfcommWithServiceRecord (in the BluetoothChat example this means never starting the "AcceptThread") the problem was fixed.
Even though these two calls are supposed to be totally separated and have no affect on each other (according to the Android docs), simply commenting out listenUsingRfcommWithServiceRecord fixed my supposedly unrelated issue.
I can take the Bluetooth Chat program unedited and it will not be able to establish an outgoing connection to ANY bluetooth device I have tested (laptops, desktops, headsets, etc.), but if I remove that one thing it works flawlessly as a client.
Anyway, I hope this will help someone else if they come across the same issue. This must be a bug with the Android OS, or possibly the firmware on the Nexus One.
I would ignore the stopDiscovery error - its good that you're cancelling discovery before making your connection. Per the SDK docs:
Because discovery is a heavyweight
precedure for the Bluetooth adapter,
this method should always be called
before attempting to connect to a
remote device with connect().
Discovery is not managed by the
Activity, but is run as a system
service, so an application should
always call cancel discovery even if
it did not directly request a
discovery, just to be sure.
So with that said, were you able to get the Bluetooth Chat example to work before you made any modifications to the code?
The UUID you want for SPP/RFCOMM is:
static UUID UUID_RFCOMM_GENERIC = new UUID(0x0000110100001000L,0x800000805F9B34FBL);
or defined another way (both accomplish the same thing).
static final UUID UUID_RFCOMM_GENERIC = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");