Tellstick DUO and tomcat

Moderator: Telldus

Post Reply
tellstick
Posts: 11
Joined: Thu Jan 18, 2018 11:08 am

Tellstick DUO and tomcat

Post by tellstick » Thu Jan 18, 2018 11:08 am

Hi,

I just bought my Tellstick DUO and it's great. I have, however, a small issue with call-backs in a spring based application running on tomcat. For some reason it stops calling my call-back method after 20-24 invocations. As a test I used more or less the same code as in the Java example SensorsJNACallback.java. When I run this standalone it works fine but when I run it as a spring based app on tomcat it get's the behaviour mentioned above... It probably not a tellstick issue (thread issue?).

micke.prag
Site Admin
Posts: 2242
Joined: Thu Jan 18, 2018 11:08 am
Location: Lund
Contact:

Re: Tellstick DUO and tomcat

Post by micke.prag » Thu Jan 18, 2018 11:08 am

I have not a clue about tomcat since I have never used it.
But the callbacks from telldus-core is executed by a new thread. Maybe you should find a way to switch it over to some "tomcat thread"?
Micke Prag
Software
Telldus Technologies

tellstick
Posts: 11
Joined: Thu Jan 18, 2018 11:08 am

Re: Tellstick DUO and tomcat

Post by tellstick » Thu Jan 18, 2018 11:08 am

I have also noticed now that the stand alone java program stops receiving call backs but after a couple of hours. Anyone that have succeeded in doing a java app that actually works?

hazzem
Posts: 13
Joined: Thu Jan 18, 2018 11:08 am

Re: Tellstick DUO and tomcat

Post by hazzem » Thu Jan 18, 2018 11:08 am

I currently have the same problem on my Windows XP running Tomcat 6.

I have a light sensor and a thermometer sending data, so there are plenty of incoming callbacks to the application.

Looking in my application log there are loads of callbacks from the thermometer. It seems to receive data twice every 30-40 seconds. Though sometimes the reading just does not seem to come through, but then it starts again. It could be minutes or hours in between these cases. Eventually it stops until the Tomcat is restarted. It seems to be disturbed when also sending out data on the Tellstick. Maybe this is something to look into?

Sending out events to toggle the remote switches does always seem to work perfectly no matter what, so it is just the callbacks that stops getting through properly after a while.

If it helps I can submit parts of my logs to be able to look into what is received and any clashes between sending and receiving data via Tellstick simoultaneously.

Regards
/Hazze

Zapper
Posts: 212
Joined: Thu Jan 18, 2018 11:08 am
Location: Där det är kallt

Re: Tellstick DUO and tomcat

Post by Zapper » Thu Jan 18, 2018 11:08 am

Have you tried the pure java lib ? There is only a small bug in the event handling that can be easily fixed. There should be info about it here on the forum.

hazzem
Posts: 13
Joined: Thu Jan 18, 2018 11:08 am

Re: Tellstick DUO and tomcat

Post by hazzem » Thu Jan 18, 2018 11:08 am

Thanks for the tip! It looks very promising... But does it work from Windows? It seems there might be some problems with that?

hazzem
Posts: 13
Joined: Thu Jan 18, 2018 11:08 am

Re: Tellstick DUO and tomcat

Post by hazzem » Thu Jan 18, 2018 11:08 am

I am still curious if you have found out why the callbacks stops after a while? I still have the same problem running TelldusCenter 2.1.2.

Anybody else having the same issue? Have you guys at Tellsdus any idea why the callbacks stop getting through?

Regards
/Hazze

Zapper
Posts: 212
Joined: Thu Jan 18, 2018 11:08 am
Location: Där det är kallt

Re: Tellstick DUO and tomcat

Post by Zapper » Thu Jan 18, 2018 11:08 am

hazzem wrote:I am still curious if you have found out why the callbacks stops after a while? I still have the same problem running TelldusCenter 2.1.2.

Anybody else having the same issue? Have you guys at Tellsdus any idea why the callbacks stop getting through?

Regards
/Hazze
If you are using JTelldus
One thing I did to stop it was to patch TelldusClient to prevent the buffer overflow that happens when more than one message come in in the socket in one read.
Did this long ago so I'm not sure it still works.

Code: Select all

/**
	 * Main loop for separate Thread. keeps connection to event socket alive and
	 * reads events.
	 */
	@Override
	public void run() {
		while (run) {
			if (!events.connect()) {
				try {
					Thread.sleep(1000);
				} catch (Exception e) {
				}
				continue;
			}

			try {
				// Use same buffer size as ClientCommunicationHandler.cpp
				ByteBuffer bb = ByteBuffer.allocate(2000);
				while (run) {
					log.trace("Reading...");
					int len = events.read(bb);

					// Added this so that it will process all incomming msg on each read
					// As there can be more than one.
					while (bb.position() > 0) {
						
						if (!Message.nextIsString(bb)) {
							throw new IllegalStateException("Illegal data in buffer, expected string");
						}



						Message msg = new Message(bb);
						if (!handleEvent(msg)) {
							// Unhandled; clear out bb
							bb.clear();
						}
					}

				}
			} catch (ClosedByInterruptException ex) {
				// Most likely close() was called; run will be false.
			} catch (IOException ex) {
				log.error("Error talking to telldusd", ex);
			} catch (IllegalStateException ex) {
				log.error("Unexpected state", ex);
				// Disconnect and hope a reconnect solves it.
				try {
					events.disconnect();
				} catch (IOException e) {
				}
			}
		}
	}

Post Reply