localhost socket stuck with specific data ? - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: localhost socket stuck with specific data ? (/showthread.php?tid=5515) |
localhost socket stuck with specific data ? - Hadeel - 16.07.2024 Hi! I have a project with Lutron integration and I follwed the thread below to setup Lutron library. https://forum.logicmachine.net/showthrea...ght=lutron As I have a lot of group addresses which requires to send command to Lutron server, I have setup localhost socket inside LM as always, in order to unite the place to open TCP port for Lutron. My scripts are below. Event script to simulate Lutron button press and release. Code: --1 ALL ON Resident script which collects the udp information and send to Lutron server (address "10/1/2" indicates if there is a conection error with Lutron server) Code: require('user.lutron') When I execute the event above, this is what I can see in the log. For some reason, when I send val 18 or 19 to press dim up /down button on lutron I cannot send button release command (val 20 or 21) within next 20 seconds even though I simulate to press them way earlier than that. This happens only when I send val 18 or 19 to this event....how am I making the socket stuck? RE: localhost socket stuck with specific data ? - admin - 17.07.2024 You resident script opens a new connection for each message that should be sent. At some point the connection limit is reached. You can try opening the connection and sending the command directly from the event script. Otherwise the resident script must be modified to have only a single open connection. RE: localhost socket stuck with specific data ? - Hadeel - 17.07.2024 Thank you for your reply! OK.....I guess it is because the resident script runs lutron_login() every time? Does this code look better? Code: require('user.lutron') RE: localhost socket stuck with specific data ? - admin - 18.07.2024 Try this. It will try sending the data again if the first send call failed due to a closed socket or any other error. Remove log() calls once you get it working. Code: if not server then RE: localhost socket stuck with specific data ? - Hadeel - 18.07.2024 Thank you so so much! It works and I don't see the send delay anymore.... internal socket does not get stuck also. I guess I am opening TCP port each time I run this resident script as well ? I tried to edit them like you did but I am failing....could you suggest how to modify it to have only a single open connection? Code: require('user.lutron') By the way in this project we have iOS tablet app and phone app but the frontend does not have functionality to prevent user from continuously clicking on the command button. That is why I put os.sleep(0.3) every time after sending TCP command but do you have better way to prevent high load caused by users' over-clicking ? Thank you very much for your help as always! RE: localhost socket stuck with specific data ? - Hadeel - 22.07.2024 Trying to work on this but I am still keep failing.... With the status script above(with 0 sec interval), I figured out new connection is open every 10 seconds. I guess it is because of the timeout that I set inside lutron_connect script Code: function lutron_connect() What I have tried with modifying status script is as below but it creates an infite roop inside LM.... Appreciate a lot if you could help. Thank you so much! Code: if not tcp then RE: localhost socket stuck with specific data ? - admin - 22.07.2024 Try this: Code: if not tcp then |