Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Previous section Next section Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Topic:
ProntoScript: sockets used too many times?
This thread has 6 replies. Displaying all posts.
Post 1 made on Monday October 10, 2022 at 05:31
Fbrighi
Long Time Member
Joined:
Posts:
September 2010
52
Hello, i programmed a control system for my home cinema, using a script on a modified Pronto Pro to run simulator directly from the PC. The normal script is able to control a projector, a denon amplifier and lights interface (through extender + Rs232) and a Zidoo mediaplayer (through LAN, using synchronous TCP socket commands).

Now, to remove the RFX9600 extenders from the system - they are big and take lot of space - I'm going to revert all controls through LAN. This because both projector and ampli has IP control possibility.

I tested singularly projector and ampli IP controls, using this function:

function LanSending(TargetIP,TargetPort,CommandString)
{
var SocketLan = new TCPSocket(true);
SocketLan.connect(TargetIP,TargetPort,3000);
SocketLan.write(CommandString);
System.delay(50);
SocketLan.close();
}

Using correct parameters, both device work good. But, when they are inserted within the normal control window - which uses several different socket instances to Zidoo to get continuosly its status (play/stop/pause, elapsed time, remaining time, ecc) - after some time system it collapses. reporting the error "failed to connect".

Viceversa, by using rs232 + extenders as before, even with several socket related to Zidoo "supervisioning" active at same moment, no collapse have ever been experienced.

I'm starting to think that the added sockets instances caused a kind of overflow...may it be related to that? Is there any type of way to reduce the socket "memory" reservation, once it ended its duty? Using asynchronous socket is not a possibility, as doing so the query request and related command would no be at same time, causing problems in control.

Thanks!

Federico
FKB
Post 2 made on Monday October 10, 2022 at 19:38
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,992
You should consider using try/catch around each of those statements and logging any errors with System.print() that you find.

Not sure why you are using System.delay(50) especially since you are not receiving any data. You are effectively halting the entire pronto for 50ms when you do this.

If, for example, your LanSending function throws an error, you could 'leak' a socket if you don't execute SocketLan.close().

Now, note that there are a max of 32 sockets allowed on the Pronto. See Dev Guide A.13.3.1. TCPSocket.setSocketLimit().

I'd do the following within your function (You will need to reformat the tabs/indentation below:

function LanSending(TargetIP,TargetPort,CommandString)
{
System.setDebugMask(9);
var SocketLan;
try {
SocketLan = new TCPSocket(true);
SocketLan.connect(TargetIP, TargetPort, 3000);
SocketLan.write(CommandString);
} catch(err) {
System.print(err.substring(0,90));
Diagnostics.log(err.substring(0,90));
}
if (SocketLan) {
try {SocketLan.close();} catch(err){
System.print(err.substring(0,90));
Diagnostics.log(err.substring(0,90));
}
SocketLan = null;
}
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 3 made on Thursday October 13, 2022 at 10:28
Fbrighi
Long Time Member
Joined:
Posts:
September 2010
52
Thanks Lyndell.
I tried your modifications. Result is that now the entire execution (i.e. also others sockets) are all completed. But, still, after some correctly executed commands (using the modified function), at one point it stops working. The interesting fact is that no error is reported at all...even in debugging window.

May it be related to the device itself? I mean the ampli which i'm controlling using the socket.

Anyway the function now looks like improved, as the process does not collpse at certain point. Only the ampli still "freeze" (meaning that he does not react) at LAN commands.

FKB
FKB
Post 4 made on Thursday October 13, 2022 at 22:41
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,992
Errors are not reported unless you use try/catch and send the output to System.print or Diagnostics.log.

Also, to see things in the ProntoScript debug console, you must do System.setDebugMask(9);

If you have a simplified (not your entire config) of what you are trying to do and want to email it to me, I'll have a look.

Lyndel
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 5 made on Sunday October 16, 2022 at 19:26
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,992
Ping back here if you do send me a file so I know to look in my spam folder if it does not show up.

Thanks,
Lyndel
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 6 made on Monday October 17, 2022 at 04:01
Fbrighi
Long Time Member
Joined:
Posts:
September 2010
52
Hello Lyndel, i sent you a mail with the required data. Thanks for your help :)!!!

Federico

Last edited by Fbrighi on October 17, 2022 05:08.
FKB
Post 7 made on Thursday October 20, 2022 at 19:10
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,992
Got the file, sent you some suggestions. Based on your current design, we may not be able to solve all the problems but hoping my suggestions will at least keep sockets cleaner.

There's a way to also set how many sockets that the Pronto can use.

TCPSocket.setSocketLimit(64);

Rather than bump this value which will only hide issues in code, you should consider decreasing to say 8 or 6 from 32. This way, you will start to see more errors if you are using more sockets than you think your code is truly written to use.
Lyndel McGee
Philips Pronto Addict/Beta Tester


Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse