SageTV Community  

Go Back   SageTV Community > SageTV Products > SageTV Software

Notices

SageTV Software Discussion related to the SageTV application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the SageTV software application should be posted here. (Check the descriptions of the other forums; all hardware related questions go in the Hardware Support forum, etc. And, post in the customizations forum instead if any customizations are active.)

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-30-2020, 02:35 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,078
Anyone know about SageTV Client port numbers / context?

I have written a driver for IP control of SageTV from Control4 using the webremote types of commands. This works well with miniclients as they use the MAC ID and that stays constant.

But things are not so simple for SageTV Client. The context for SageTV Client is the IP address plus a port number and the port number seems to change every time the client restarts.

You can see this client number and the context when hovering over this client name from the SageTV web UI home page. For example, right now I see
Code:
http://192.168.1.99:7070/sage/ExtenderDetails?context=%2F192.168.1.98%3A64862
And the 64862 is the port number. But a few minutes ago before restarting that port number was 64253.

Why does this port number change, and is there any way to keep it constant?
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
  #2  
Old 11-30-2020, 04:41 PM
ojones ojones is offline
Sage User
 
Join Date: Dec 2005
Posts: 33
Wayne - Thanks for posting this! I know this has come up in the past for other developers - EnterNoEscape - I think might have run into it (trying to obtain the full context for each client including port).

If anyone has any ideas or pointers I would be very grateful! Using Wayne's control4 driver I am very close to seamless remote control for my HTPC clients.

Alternatively, if anyone knows how to form the HTTP messages to command clients via IP or MAC alone without specifying the client listening port that might also do the trick!

-Owen
Reply With Quote
  #3  
Old 11-30-2020, 04:54 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,078
Owen - the other way to skin this cat, although less elegant, would be to send keyboard commands to the PC. This could be done via IR or IP but would be much less elegant of a solution, but would have the advantage of being able to have the PC start the SageTV client app.

Former C4 executive Charles Kindel built the MCE Controller app for PCs starting 16 years ago and he still maintains it - it is on Github: https://github.com/tig/mcec.

Quote:
MCE Controller provides robust remote control a Windows HTPC (or any PC) over the network. It runs in the background listening on the network (or serial port) for commands. It then translates those commands into actions such as keystrokes, text input, and the starting of programs. Any remote control, home control system, or application that can send text strings via TCP/IP or a serial port can use MCE Controller to control a Windows PC.
And Garry Newman did a C4 driver: https://github.com/garrynewman/Contr...ntrollerDriver

So using MCEC is a potential solution to this problem as well if we can't solve the problem from the SageTV server side.
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
  #4  
Old 11-30-2020, 10:35 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,078
FYI - the way that we are solving this is that we have installed an instance of the SageTV web UI on the client. Then we are using a connection to that client with a context of SAGETV_PROCESS_LOCAL_UI to be able to control the client.

It is the same as using the Web Remote with the server, except you are using the IP address and port of the client's instance of SageTV web server and you are using as the context ID instead of a miniclient's MAC or the client's IP address/port.

So the command
Code:
http://192.168.1.98:8081/sage/SageCommand?context=SAGETV_PROCESS_LOCAL_UI&command=Down
is the same as pusing the down button on the remote or keyboard of SageTVClient running on an IP of 192.168.1.98 on port 8081
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
  #5  
Old 12-01-2020, 11:35 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,635
If the sagex apis are installed you can call the GetUIContextNames (or maybe GetConnectedClients) and use that information to determine the correct context.
http://download.sage.tv/api/sage/api...IContextNames()

https://github.com/stuckless/sagetv-...sing-sagex-api
Reply With Quote
  #6  
Old 12-01-2020, 11:52 AM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,078
Quote:
Originally Posted by stuckless View Post
If the sagex apis are installed you can call the GetUIContextNames (or maybe GetConnectedClients) and use that information to determine the correct context.
http://download.sage.tv/api/sage/api...IContextNames()

https://github.com/stuckless/sagetv-...sing-sagex-api
Yes, actually the GetConnectedClients Sagex call is what I need. Using JSON encoding I get this returned: {"Result":["/192.168.1.98:62142"]}

@stuckless - Any idea why the client uses a different port every time it connects to a server. Is there any way to force it to use a constant port number?
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
  #7  
Old 12-01-2020, 01:08 PM
wnjj wnjj is online now
Sage Icon
 
Join Date: Jan 2009
Posts: 1,388
Quote:
Originally Posted by wayner View Post
Yes, actually the GetConnectedClients Sagex call is what I need. Using JSON encoding I get this returned: {"Result":["/192.168.1.98:62142"]}

@stuckless - Any idea why the client uses a different port every time it connects to a server. Is there any way to force it to use a constant port number?
In order to support multiple clients, wouldn’t they have to use unique port numbers? Typically TCP/IP connections are opened under a “common” port and a new, semi-random port is used for further communication for that specific client.

From http://www.steves-internet-guide.com...-ports-sockets

“Ports 49152-65535– These are used by client programs and you are free to use these in client programs. When a Web browser connects to a web server the browser will allocate itself a port in this range. Also known as ephemeral ports.”

https://en.m.wikipedia.org/wiki/Ephemeral_port
__________________
Windows Installer
Reply With Quote
  #8  
Old 12-01-2020, 02:04 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,078
I guess it would just be easier if those ports weren't epehmeral and you could assign a specific port to each client for control. If I remember correctly this is how Fonceur's SacgeTCP used to work.
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SageTV V7 - API: FindWidgetBySymbol on remote UI context shadeblue.com SageTV Beta Test Software 10 07-17-2010 12:45 AM
SageTV Not Opening Com Port (Using Digi realport multi-port serial adapter) personalt Hardware Support 0 06-09-2010 07:02 PM
Firewall and port numbers KeAuraPete SageTV Software 5 12-24-2003 12:59 PM
What port does SageTv listen for client on rkn555 SageTV Software 3 12-01-2003 06:49 PM


All times are GMT -6. The time now is 10:20 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.