NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
1 2 3 4 5 … 93 Next »
Invalid session?

 
  • 0 Vote(s) - 0 Average
Invalid session?
mandai
Offline

Junior Member

UK
Posts: 9
Threads: 1
Joined: Nov 2020
#1
2021-07-24, 10:14 PM
Hi I am trying to get the EPG data from this URL
http://127.0.0.1:8866/services/service?m...gs.current

but it gives this response
<?xml version="1.0" encoding="utf-8" ?>
<rsp stat="fail">
  <err code="8" msg="Invalid Session" />
</rsp>


This has only happened after I updated to version 5.1.3.210711. Is there any way to fix this?
I have ticked the options for Allow remote access/Allow unauthenticated access (this is only accessed locally).
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,671
Threads: 767
Joined: Nov 2003
#2
2021-07-24, 10:21 PM
Generally you need to be logged in to call those urls, and supply a sid on the url.

You can probably set <AutoAuthLocalConnections>true</AutoAuthLocalConnections> in the <WebServer> section of config.xml.
mandai
Offline

Junior Member

UK
Posts: 9
Threads: 1
Joined: Nov 2020
#3
2021-07-24, 11:10 PM
Thanks it is working after editing the config.xml file  Smile
topcat
Offline

Member

United Kingdom
Posts: 85
Threads: 15
Joined: Feb 2007
#4
2024-02-29, 09:16 PM
http://localhost/services/service?method...el_id=8574

This used to work for me, but i'm now getting a 500 error

Version: 6.1.5.231022

error log:
2024-02-29 21:14:12.538 [DEBUG][66] Got request [#########]: /services/service (channel.listings.current)
2024-02-29 21:14:12.538 [DEBUG][66] method=channel.listings.current
2024-02-29 21:14:12.538 [DEBUG][66] parameters:
2024-02-29 21:14:12.538 [DEBUG][66] method: channel.listings.current
2024-02-29 21:14:12.538 [DEBUG][66] format: json
2024-02-29 21:14:12.539 [DEBUG][66] channel_id: 8574
2024-02-29 21:14:12.539 [DEBUG][66] client_ip: ##########
2024-02-29 21:14:12.539 [DEBUG][66] user_agent: ##################
2024-02-29 21:14:12.539 [DEBUG][66] host_callback: ...
2024-02-29 21:14:12.539 [DEBUG][66] sid: default
2024-02-29 21:14:12.540 [ERROR][66] System.Collections.Generic.KeyNotFoundException: The given key 'default' was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at NShared.Extend.SecurityHelper.CheckSIDActive(String clientIP, String sid)
at NShared.Extend.BaseRequestHandler.SessionIsActive(Dictionary`2 parameters)
at NShared.Extend.ChannelRequestHandler.GetCurrentListings(Dictionary`2 parameters)
at NShared.Extend.ChannelRequestHandler.HandleRequest(String method, Dictionary`2 parameters)
at NShared.Extend.PluginFactory.HandleRequest(ServiceResponseStream serviceResponseStream, Dictionary`2 parameters)
at NPVR.Controllers.ServicesController.HandleServiceRequest(String body, String contentType)
NPVR: 6
Windows 10 Enterprise
Hauppauge WinTV Dual Nova-T DVB-T
TBS Dual 6982 DVBS/S2
SSD System and Live
2TB Recording Store
Windows KODI Clients, OSMC (Kodi) Hardware Clients, Android Kodi Clients, Custom Direct URI players.
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 52,849
Threads: 954
Joined: May 2006
#5
2024-02-29, 09:40 PM
You need to pass a valid sid. What client is this?

Martin
topcat
Offline

Member

United Kingdom
Posts: 85
Threads: 15
Joined: Feb 2007
#6
2024-03-01, 10:39 AM
(2024-02-29, 09:40 PM)mvallevand Wrote: You need to pass a valid sid.  What client is this?

Martin

okay, i've not needed to in the past (well months ago) i had not noticed the failures.

This is a custom script that calls the URI for a channelID to see what is on.
Written in python, so a standard json call.
NPVR: 6
Windows 10 Enterprise
Hauppauge WinTV Dual Nova-T DVB-T
TBS Dual 6982 DVBS/S2
SSD System and Live
2TB Recording Store
Windows KODI Clients, OSMC (Kodi) Hardware Clients, Android Kodi Clients, Custom Direct URI players.
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 52,849
Threads: 954
Joined: May 2006
#7
2024-03-01, 02:58 PM (This post was last modified: 2024-03-01, 11:28 PM by mvallevand.)
I guess this call doesn't work with the Unauthenticated Access setting after sub increased some API security. This will get you a sid

Code:
from urllib.request import urlopen,Request
import json
import sys

ip= "localhost"
port = "8866"
pin = "0000"

def doRequest5(method, sid = None):
    retval = False
    getResult = None
    url = "http://" + ip + ":" + str(port) + '/service?method=' + method
    if (not 'session.initiate' in method):
        url += '&sid=' + sid
    try:
        print (url)
        request = Request(url, headers={"Accept" : "application/json", 'User-Agent': 'getsid', 'host': 'localhost'})
        json_file = urlopen(request)
        getResult = json.load(json_file)
        json_file.close()
        retval = True
    except Exception as e:
        print(str(e))

    return retval, getResult

def hashMe (thedata):
    import hashlib
    h = hashlib.md5()
    h.update(thedata.encode('utf-8'))
    return h.hexdigest()


def  sidLogin5():
    method = 'session.initiate&ver=1.0&device=getsid'
    ret, keys = doRequest5(method)
    if ret == True:
        sid =  keys['sid']
        salt = keys['salt']
        hm = hashMe(str(pin.zfill(4)))
        method = 'session.login&md5=' + hashMe(':' + hm + ':' + salt)
        ret, login  = doRequest5(method, sid)
        print (ret, login)
        if ret and login['stat'] == 'ok':
            sid =  login['sid']
        else:
            print ("Fail 2")
    else:
        print ("Fail")

if __name__== "__main__":
    sidLogin5()


Martin
topcat
Offline

Member

United Kingdom
Posts: 85
Threads: 15
Joined: Feb 2007
#8
2024-03-08, 05:53 PM
(2024-03-01, 02:58 PM)mvallevand Wrote: I guess this call doesn't work with the Unauthenticated Access setting after sub increased some API security.  This will get you a sid

Martin


Perfect, many thanks, that worked a treat

Have wrapped into class.
Still a work in progress

GitHub - topcats/rpi_AudioPlayer: Python Audio Player using VLC, and json Schedule
NPVR: 6
Windows 10 Enterprise
Hauppauge WinTV Dual Nova-T DVB-T
TBS Dual 6982 DVBS/S2
SSD System and Live
2TB Recording Store
Windows KODI Clients, OSMC (Kodi) Hardware Clients, Android Kodi Clients, Custom Direct URI players.
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 52,849
Threads: 954
Joined: May 2006
#9
2024-03-08, 06:32 PM
To autoplay on a schedule in Kodi I'd probably just create reminders. This could be done with iptvsimple and no backend but if you used NextPVR you could even have the reminder record or autoplay.

Martin
topcat
Offline

Member

United Kingdom
Posts: 85
Threads: 15
Joined: Feb 2007
#10
2024-03-19, 05:22 PM
(2024-03-08, 06:32 PM)mvallevand Wrote: To autoplay on a schedule in Kodi I'd probably just create reminders.  This could be done with iptvsimple and no backend but if you used NextPVR you could even have the reminder record or autoplay.

Martin

We use NextPVR for all house media anyway, it was just easier to link with.

And for the Audio radio player, it runs on a headless PI
NPVR: 6
Windows 10 Enterprise
Hauppauge WinTV Dual Nova-T DVB-T
TBS Dual 6982 DVBS/S2
SSD System and Live
2TB Recording Store
Windows KODI Clients, OSMC (Kodi) Hardware Clients, Android Kodi Clients, Custom Direct URI players.
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode