Java MIDlet stops working when executed from BGS5T | Telit Cinterion IoT Developer Community
November 10, 2016 - 10:59am, 5173 views
Hello.
I've built an app which controls an equipment via Webserver. This app works perfectly when executed by IDE. However, when I run it on "stand-alone" mode from the modem, It works fine for some minutes but stops working after a while, failing to deliver my requests. Could it be some configuration on the modem mode or the .jad file?
The output for AT^SCFG?
AT^SCFG?AT^SCFG?
^SCFG: "Call/ECC","0"
^SCFG: "GPRS/AutoAttach","enabled"
^SCFG: "Gpio/mode/ASC1","std"
^SCFG: "Gpio/mode/DAI","gpio"
^SCFG: "Gpio/mode/DCD0","std"
^SCFG: "Gpio/mode/DSR0","std"
^SCFG: "Gpio/mode/DTR0","std"
^SCFG: "Gpio/mode/FSR","gpio"
^SCFG: "Gpio/mode/PULSE","gpio"
^SCFG: "Gpio/mode/PWM","gpio"
^SCFG: "Gpio/mode/RING0","std"
^SCFG: "Gpio/mode/SPI","rsv"
^SCFG: "Gpio/mode/SYNC","std"
^SCFG: "Ident/Manufacturer","Cinterion"
^SCFG: "Ident/Product","BGS5"
^SCFG: "MEShutdown/Fso","0"
^SCFG: "MEopMode/SoR","on"
^SCFG: "Radio/Band","15"
^SCFG: "Radio/OutputPowerReduction","4"
^SCFG: "Serial/Interface/Allocation","1","1"
^SCFG: "Serial/USB/DDD","0","0","0409","1E2D","0059","Cinterion Wireless Modules","Cinterion BGx USB Com Port",""
^SCFG: "Tcp/IRT","3"
^SCFG: "Tcp/MR","10"
^SCFG: "Tcp/OT","6000"
^SCFG: "Tcp/WithURCs","on"
^SCFG: "Trace/Syslog/Otap","0"
^SCFG: "URC/Ringline","local"
^SCFG: "URC/Ringline/ActiveTime","2"
^SCFG: "Userware/Autostart","1"
^SCFG: "Userware/Autostart/Delay","0"
^SCFG: "Userware/Passwd",
^SCFG: "Userware/Stdout","null",,,,"off"
^SCFG: "Userware/Watchdog","0"
OK
And for AT^SPOW?
^SPOW: 1,0,0
OK
Thanks
Hello,
I think that you should start form searching for problems inside the application itself. Running or debugging the app form the IDE slows down the application execution - maybe this is the reason why it works from IDE and there's a problem while running alone, especially if there are many threads which depend on each other.
What exactly is happening - are there any exceptions, does the application stop or just hangs? What is inside the application, what is it doing? Do you have any logs?
Please try to add some additional debug outputs that would help you to find the source of the problem.
Regards,
Bartłomiej
Basically my app is connected to a device which sends a string over serial with 2.30minutes interval. This string is sent to a Website by http request which updates the value of the variable. If the state of that variable is changed, the website sends an HTTP request, which when received by the modem, sends an SMS. Also, on the website, you can update the state of that said variable, which generates an HTTP request which makes the modem to transmit the value by serial to the device.
This is done by different classes. One for starting, which starts the methods for start serial, GPRS connection,etc, one to hold the http requests, another to make the SMS requests, etc. They are linked to each other. Could it be due to the existance of many classes doing different stuff the program stops?
I don't really know what happens when the application doesn't work. When I run the app by IDE it runs normally and I get no errors, but when running by the modem I can't really see the output, so I don't have a clue what is happening. Is there any way to see the output of the program in these conditions?
The time the program takes to stop is kind of uncertain. Last run was successful for 35 minutes. After that, the modem stopped receiving the string from the device.
Regards.
Hello,
So you have some functionalities depending on each other and as I understand you can't see any output from the application.
You should start from configuring the system output for the Java applications with AT^SCFG command.
Example:
at^scfg="Userware/Stdout","usb3"
Then add some debug prints in your app and see what's going on.
Regards,
Bartłomiej
I followed your suggestion to come to the conclusion that the program works for about 30minutes and stops, without giving any sort of error when trying to make a new http request to update the website variable.
This is the method:
Hello,
Do you know exactly in which line this stops in this method?
If this is the complete method body I can't see any debug information or stack trace printing in each exception catch block.
According to API the read() method "blocks until input data is available" - is it possible that the program stops on read() method? In such case you could use available() method first to check if there is data available.
Without the IDE the program executes faster - I still think that can matter here.
Do you use many threads and synchronization?
Regards,
Bartłomiej
Yeah, the code stops exactly at this line:
if (connection.getResponseCode() == HttpConnection.HTTP_OK) {
..
}
Yeah, I have added printouts to the exception "e" but it doesn't print anything. It's like the program freezes and doesn't even catch any exceptions
Yes I have some classes working almost at the same time:
- Serial comm always listening, waiting for an input from device.
- Socket waiting from a connection from the website.
- When a string is received from the device, it is sent to the website. If the state of the device is different from the existent, the website makes a request to send an SMS.
EDIT:
I induced some Thread.sleep among the code lines above and the working time of the project has extended by 20 minutes. Stopped again.
Thanks a lot for your help.
getResponseCode() method should not block. If you mean the whole if() block it's probably the read() method that is waiting for data which doesn't come for some reason. So please try to use some non-blocking available() and also call getLength() method on the connection before reading.
Regards,
Bartłomiej
I've deleted the entire if (connection.getResponseCode() == HttpConnection.HTTP_OK) {
..
}
and it's exceptions. I've replaced it with
con=connection.getResponseCode();
System.out.Println(con);
The program worked for 45 minutes and stopped precisely before the "con" print, which clearly leads to conclude that something is wrong with the connection settings.
Where and how would you call the .getLength method? Could it be something to do with the length of the message? (It's strange since it runs smoothly with many requests and then stops).
Regards
If the program execution hangs on getResponseCode() as you describe that would look like it happens when there is no reply form the server or some other error in communication with the server (when this method is called the request is actually sent to the server and the response code is read). The getResponseCode() should return in such case but according to your description it doesn't.
getLength() could be used later to get the length of the available data. You can find a simple example in the API.
I think that you could try to open the input stream before calling getResponseCode() and check if it helps. If not some timer could be started in a separate thread before calling getResponseCode() that would close the connection if no answer from the server.
Regards,
Bartłomiej
Hello,
Is there any new information regarding this issue? We too get some "random" reboots and we are in the process of figuring out why. We have modules that crash or reboot and we are finding different reasons for different failures, such as a bad cable, or invalid parameters; however, in many modules we find a pattern of the module completly freezing or rebooting.
@Luis_tava, when the module locks up and stops responding does the amber diode still blink as it should? Have you tried communicating with the module via terminal on a different interface?
We have some modules that seem to reboot or hard lock right around similar code that Luis_tava wrote. Some***** the modules are rebooted and other ***** they simply stop, no blinking leds and will not responde to AT commands on any interface.
Is the module's behavior well defined if you have a "read" or "getResponseCode" if the server gives no response or simply disconnects without warning such as the case with Luis_tava? I know that we have tested this and even when the server simply "dies" or give no response the module throws the appropriate exception and moves on, at least most of the time. Similar to Luis_tava's issue is that the modules that do freeze/reboot will work some***** for hours or even days before crashing.
Thanks
Pages