REST service unresponsible after systemmode change

Support questions for server and client (Windows, iPhone, Android, Linux)
Post Reply
cyberde
3 stars
3 stars
Posts: 61
Joined: Thu 11 Apr 2013, 08:00
Location: The Netherlands
Contact:

REST service unresponsible after systemmode change

Post by cyberde » Mon 28 Oct 2013, 07:22

Hello,

Today I've found out that my plugin and client programs couldn't access the REST service of SK after a systemmode change. It appears that when SK changes a scenario (either client, or via REST) the REST service becomes unresponsive for about two minutes.

Code: Select all

28-10-2013 7:14:44: SwitchKingSystemMode: received new active system mode ID: 2, Name: Night
28-10-2013 7:14:44: SwitchKingClient: Set datasource 49 to Off
28-10-2013 7:16:24: SwitchKingClient: Get datasource 39
28-10-2013 7:16:24: SwitchKingDatasource: received update ID: 49, Value: Off
In the above log you can see that my plugin sets certain DataSource values after changing a systemmode through rest (respons due to the ISystemModeEventListener implementation). My plugin also implements the IDataSourceValueEventListener, and as you can see it takes about 1.5/2 minutes for it to do the request and receive the OnSystemModeChanged event. During that time the REST service is unresponsive, also through the browser.

Just now I've gotten the following error in the SwitchKing Client as well:

Code: Select all

************** Exception Text **************
System.TimeoutException: The request channel timed out while waiting for a reply after 00:01:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout. ---> System.TimeoutException: The HTTP request to 'http://localhost:8080/SwitchKingFrameworkServiceHost' has exceeded the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout. ---> System.Net.WebException: The operation has timed out
   at System.Net.HttpWebRequest.GetResponse()
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   --- End of inner exception stack trace ---
   at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   --- End of inner exception stack trace ---
Any ideas? :)

Cheers

Martin
Administrator
Administrator
Posts: 2655
Joined: Tue 09 Nov 2010, 20:25

Re: REST service unresponsible after systemmode change

Post by Martin » Mon 28 Oct 2013, 07:30

Do you have any error messages in Switch Kings server logs?
Martin | Switch King

cyberde
3 stars
3 stars
Posts: 61
Joined: Thu 11 Apr 2013, 08:00
Location: The Netherlands
Contact:

Re: REST service unresponsible after systemmode change

Post by cyberde » Mon 28 Oct 2013, 08:04

Hi Martin,

No I don't have any error messages in the logs. It seems that the service is too busy sending out the signals to synchronize the devices after a system mode change and thus blocking the REST service.

Martin
Administrator
Administrator
Posts: 2655
Joined: Tue 09 Nov 2010, 20:25

Re: REST service unresponsible after systemmode change

Post by Martin » Mon 28 Oct 2013, 08:44

A synchronization of devices (which can occurr after a system mode change) should usually not take one or two minutes unless the system consists of many devices and that all devices have their "Send Count" turned up. Even if that would have been the case, a REST call should have been able to sneak in between two synchronization commands.

Do you have any devices that does not have a schedule connected - i.e. an empty timeline? If so, try to configure these devices so that they are not affected by schedules since they might cause heavy CPU load when Switch King tries to find a defined state.

You could also try turning on debug logging to see what really happens during the time when a REST call is made and a schedule mode has changed.
Martin | Switch King

cyberde
3 stars
3 stars
Posts: 61
Joined: Thu 11 Apr 2013, 08:00
Location: The Netherlands
Contact:

Re: REST service unresponsible after systemmode change

Post by cyberde » Mon 28 Oct 2013, 09:27

Yes devices have a sent count of 3 (with 500ms interval, should just be 4 seconds though) because if the bad reception I get sometimes, according to the history log you can see that it's synchronizing the 27 devices I have at the moment. Which does take up about 1.5/2 minutes. The indicated Server Load in SK changes to High Load, so yes maybe something is going wrong.

I'm not home at the moment, so I will try this afternoon to test it by turning on debug logging. How do I change to debug logging?

Martin
Administrator
Administrator
Posts: 2655
Joined: Tue 09 Nov 2010, 20:25

Re: REST service unresponsible after systemmode change

Post by Martin » Mon 28 Oct 2013, 09:34

Martin | Switch King

cyberde
3 stars
3 stars
Posts: 61
Joined: Thu 11 Apr 2013, 08:00
Location: The Netherlands
Contact:

Re: REST service unresponsible after systemmode change

Post by cyberde » Mon 28 Oct 2013, 10:00

Thanks, that's why I couldn't find it :)
I'll test it this afternoon and report back.

cyberde
3 stars
3 stars
Posts: 61
Joined: Thu 11 Apr 2013, 08:00
Location: The Netherlands
Contact:

Re: REST service unresponsible after systemmode change

Post by cyberde » Mon 28 Oct 2013, 16:30

I've figured out what went wrong, on a SystemModeChange my plugin immediately called the restserver/systemmodes/active call which resulted in a block somehow (that call took like 1.5 minutes to complete). Now I'm using the parameters to determine which systemmode has been activated and so far it seems to work smoothly now.

Martin
Administrator
Administrator
Posts: 2655
Joined: Tue 09 Nov 2010, 20:25

Re: REST service unresponsible after systemmode change

Post by Martin » Mon 28 Oct 2013, 16:39

How do you call the REST service? Do you use the local IP?
Martin | Switch King

cyberde
3 stars
3 stars
Posts: 61
Joined: Thu 11 Apr 2013, 08:00
Location: The Netherlands
Contact:

Re: REST service unresponsible after systemmode change

Post by cyberde » Mon 28 Oct 2013, 19:48

I'm calling it through localhost, so 127.0.0.1...

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest