Dedicated server API

Discussion in 'Community Workshop' started by J-F Chardon, Apr 23, 2018.

  1. Koenvh

    Koenvh Member

    Joined:
    Feb 3, 2020
    Ratings:
    +8 / 0 / -0
    I am working on a dashboard that shows the current session with the current players and times, along with a live map that shows where the drivers are. Something along these lines basically:
    upload_2020-5-8_17-52-19.png
    Now, I can get the list of players from the API, and I can get their positions. I can find which session it currently is (practice, qualify, etc), but I cannot find what the current track is. Is there some other way I could get this information?
     
  2. yoori

    yoori Well-Known Member

    Joined:
    Feb 10, 2017
    Ratings:
    +103 / 0 / -0
    There should be a layout id. With that from r3e-data you can get a layout name and track id, which will allow you to look up track name.
     
  3. Koenvh

    Koenvh Member

    Joined:
    Feb 3, 2020
    Ratings:
    +8 / 0 / -0
    Correct, but the layoutId is there for all tracks in the list, so how do I know which one is the current track?

    {
    "ProcessState": {
    "Running": true,
    "Port": 60000,
    "TimePort": 60002,
    "PlayersOnServer": 0,
    "TimeLeft": 899985,
    "SessionTime": 14,
    "SessionTimeLeft": 0,
    "CurrentSession": 256,
    "Players": []
    },
    "GameSetting": {
    "Id": 129121,
    "Name": "",
    "Password": "",
    "Thumbnail": "",
    "Experience": 2481,
    "DriveAssistPreset": 3,
    "DriveAssistTransmission": -1,
    "DriveAssistEsp": -1,
    "DriveAssistSteer": -1,
    "DriveAssistBrake": -1,
    "DriveAssistTractionControl": -1,
    "DriveAssistRaceline": -1,
    "DriveAssistAutopit": -1,
    "TrackLayouts": [
    {
    "LayoutId": 1672,
    "Sessions": {
    "WarmupDuration": 0,
    "Qualify": {
    "Duration": 15,
    "TimeOfDay": 2,
    "SessionType": 0
    },
    "Practice": {
    "Duration": 0,
    "TimeOfDay": 2,
    "SessionType": 1
    },
    "Race1": {
    "Duration": 15,
    "TimeOfDay": 2,
    "SessionType": 1
    },
    "Race2": {
    "Duration": 0,
    "TimeOfDay": 2,
    "SessionType": 1
    },
    "Race3": {
    "Duration": 0,
    "TimeOfDay": 2,
    "SessionType": 1
    }
    }
    },
    {
    "LayoutId": 6137,
    "Sessions": {
    "WarmupDuration": 0,
    "Qualify": {
    "Duration": 15,
    "TimeOfDay": 2,
    "SessionType": 0
    },
    "Practice": {
    "Duration": 0,
    "TimeOfDay": 2,
    "SessionType": 1
    },
    "Race1": {
    "Duration": 15,
    "TimeOfDay": 2,
    "SessionType": 1
    },
    "Race2": {
    "Duration": 0,
    "TimeOfDay": 2,
    "SessionType": 1
    },
    "Race3": {
    "Duration": 0,
    "TimeOfDay": 2,
    "SessionType": 1
    }
    }
    }
    ],
    "ReverseStartOrderPlaces": 0,
    "Cars": [
    7029,
    7011,
    7005,
    7125,
    7117,
    7036,
    7105
    ],
    "Liveries": [
    7008,
    7034,
    7033,
    7035,
    7020,
    7021,
    7016,
    7018,
    7017,
    7019,
    7031,
    7047,
    7038,
    7039,
    7107,
    7108,
    7121,
    7123,
    7119,
    7122,
    7128,
    7130,
    7131,
    7129,
    7132,
    7133
    ],
    "MaxNumOfPlayers": 10,
    "FuelUsage": 1,
    "TireWear": 1,
    "Damage": 1,
    "RaceFinishDuration": 30,
    "FlagRules": 2,
    "CutRules": 0,
    "StateReportInterval": 3000,
    "KickNonReadyClientsTime": 0,
    "CompressionLevel": 3,
    "WreckerPrevention": 0,
    "MandatoryPitstop": 0,
    "NonReadyPitlaneStartDelay": 0,
    "StayInPracticeSessionIfEmpty": 1,
    "AllowPlayersJoinInQualifying": 1,
    "CheckeredAfterTime": 30,
    "MaxPing": 0,
    "FixedSetup": 0,
    "TimeOfDayMultiplier": 1,
    "AdPack": null,
    "RankedServer": 0,
    "MaxIncidentPoints": 0,
    "MinRating": 0,
    "MinReputation": 0,
    "RestartRequested": null
    }
    }

    How do you know whether 6137 or 1672 is now active?
     
  4. yoori

    yoori Well-Known Member

    Joined:
    Feb 10, 2017
    Ratings:
    +103 / 0 / -0
    the top one, it will change the first element in the array is always current track.
    Or it should, be haven't played with this json. it worrks like that for the ranked servers json
     
  5. Koenvh

    Koenvh Member

    Joined:
    Feb 3, 2020
    Ratings:
    +8 / 0 / -0
    That's the funny thing - I expected that to be the case too, however:
    Code:
    {
      "ProcessState": {
        "Running": true,
        "Port": 60000,
        "TimePort": 60002,
        "PlayersOnServer": 1,
        "TimeLeft": 259230,
        "SessionTime": 640769,
        "SessionTimeLeft": 0,
        "CurrentSession": 256,
        "Players": [
          {
            "UserId": 11962,
            "X": -353.341,
            "Z": -21.355,
            "CarLiveryId": 7121,
            "Incidents": [],
            "LatestPingMilliSec": 7.6348
          }
        ]
      },
      "GameSetting": {
        "Id": 129121,
        "Name": "",
        "Password": "",
        "Thumbnail": "",
        "Experience": 2481,
        "DriveAssistPreset": 3,
        "DriveAssistTransmission": -1,
        "DriveAssistEsp": -1,
        "DriveAssistSteer": -1,
        "DriveAssistBrake": -1,
        "DriveAssistTractionControl": -1,
        "DriveAssistRaceline": -1,
        "DriveAssistAutopit": -1,
        "TrackLayouts": [
          {
            "LayoutId": 1672,
            "Sessions": {
              "WarmupDuration": 0,
              "Qualify": {
                "Duration": 15,
                "TimeOfDay": 2,
                "SessionType": 0
              },
              "Practice": {
                "Duration": 0,
                "TimeOfDay": 2,
                "SessionType": 1
              },
              "Race1": {
                "Duration": 15,
                "TimeOfDay": 2,
                "SessionType": 1
              },
              "Race2": {
                "Duration": 0,
                "TimeOfDay": 2,
                "SessionType": 1
              },
              "Race3": {
                "Duration": 0,
                "TimeOfDay": 2,
                "SessionType": 1
              }
            }
          },
          {
            "LayoutId": 6137,
            "Sessions": {
              "WarmupDuration": 0,
              "Qualify": {
                "Duration": 15,
                "TimeOfDay": 2,
                "SessionType": 0
              },
              "Practice": {
                "Duration": 0,
                "TimeOfDay": 2,
                "SessionType": 1
              },
              "Race1": {
                "Duration": 15,
                "TimeOfDay": 2,
                "SessionType": 1
              },
              "Race2": {
                "Duration": 0,
                "TimeOfDay": 2,
                "SessionType": 1
              },
              "Race3": {
                "Duration": 0,
                "TimeOfDay": 2,
                "SessionType": 1
              }
            }
          }
        ],
        "ReverseStartOrderPlaces": 0,
        "Cars": [
          7029,
          7011,
          7005,
          7125,
          7117,
          7036,
          7105
        ],
        "Liveries": [
          7008,
          7034,
          7033,
          7035,
          7020,
          7021,
          7016,
          7018,
          7017,
          7019,
          7031,
          7047,
          7038,
          7039,
          7107,
          7108,
          7121,
          7123,
          7119,
          7122,
          7128,
          7130,
          7131,
          7129,
          7132,
          7133
        ],
        "MaxNumOfPlayers": 10,
        "FuelUsage": 1,
        "TireWear": 1,
        "Damage": 1,
        "RaceFinishDuration": 30,
        "FlagRules": 2,
        "CutRules": 0,
        "StateReportInterval": 3000,
        "KickNonReadyClientsTime": 0,
        "CompressionLevel": 3,
        "WreckerPrevention": 0,
        "MandatoryPitstop": 0,
        "NonReadyPitlaneStartDelay": 0,
        "StayInPracticeSessionIfEmpty": 1,
        "AllowPlayersJoinInQualifying": 1,
        "CheckeredAfterTime": 30,
        "MaxPing": 0,
        "FixedSetup": 0,
        "TimeOfDayMultiplier": 1,
        "AdPack": null,
        "RankedServer": 0,
        "MaxIncidentPoints": 0,
        "MinRating": 0,
        "MinReputation": 0,
        "RestartRequested": null
      }
    }
    
    And this was captured when the qualifying was underway at Knutstorp, which is the second race in the list.
     
  6. Koenvh

    Koenvh Member

    Joined:
    Feb 3, 2020
    Ratings:
    +8 / 0 / -0
    @J-F Chardon I noticed that the Discord bot can display the current tracks on the servers using !servers, and according to @yoori the first track listed for the ranked servers is the track that is driven now. Is it a bug that this is not the case for the community server, and thus it is not possible to find out what the current track is from the dedicated server API? Or is there another way to get this information? Likewise, I noticed that the players from the /dedi/{ProcessID} endpoint (inside ProcessState) are not listed in the order of their current position in the race, but in the order that the players joined. Is there another way to determine the current position (whilst also taking into account lapped cars)?
     
    • Agree Agree x 1
  7. LaundroMat

    LaundroMat Member

    Joined:
    Nov 28, 2020
    Ratings:
    +15 / 0 / -0
    You should update the section on the API in the "Multiplayer Dedicated How-To" post.

    I spent last night trying to figure out the API by analysing the requests done by the web front-end before I stumbled on this page today :rolleyes:
     
    Last edited: Dec 7, 2020
  8. CaptainCoffee

    CaptainCoffee Esports Manager Beta tester

    Joined:
    Oct 11, 2020
    Ratings:
    +196 / 0 / -0
    It's a late reply, but the only reason why the Bot knows what track is used is because the Ranked servers have 1 track per server.

    As far as I know, it's not possible to get the relevant positions/times through the dedi api, that data is only available from within the game. Workaround would be to join as spectator and have the spectator overlay export the users and current track in a file (not entirely sure if that works tho)
     
    • Like Like x 2
  9. ACX_Com

    ACX_Com New Member

    Joined:
    May 18, 2020
    Ratings:
    +2 / 0 / -0
    Hello together.
    can anybody help me on my following questions/issues?

    1. Laggs...
    When dedicated server run's on dedicated computer (simple Windows 10 Pro 64 client Computer), performance are good without any laggs.
    But when dedi server run's on "VM" Win 10 Pro 64 (on my Server OS FreeNAS/TrueNAS with enought powerfull 6 core 4,9 GHz and 6GB RAM) the car's are jumping around my 50m to the front then back of me ore on my place - i hope you know what i meen. ;)

    2. bugy?
    Every Night the server lost his settings, connections to the server i think and i found much is not working as it should!
    Example:
    Yesterday the server was not switching after end of Race/Track to the next and hangs in this.
    Nobody can join.

    3. generally...
    Is enywhere a very good supported forum or website, there i can find info and support to dedi sever?
    ...or is this the best? ;)
     
  10. CaptainCoffee

    CaptainCoffee Esports Manager Beta tester

    Joined:
    Oct 11, 2020
    Ratings:
    +196 / 0 / -0
    Hi ACX_Com,

    This topic is specifically about the dedicated server API. It's better to create a new topic specifically for your problem in https://forum.sector3studios.com/index.php?forums/community-support.54/

    In short, the portforwarding goes from the router to your nas and then on a virtual machine, it's a difficult one to debug but it might be too much layers for the network to work good. But like I said, create a new topic and I'm sure somebody will help you
     
    • Like Like x 1
  11. LaundroMat

    LaundroMat Member

    Joined:
    Nov 28, 2020
    Ratings:
    +15 / 0 / -0
    Is it possible to access the API from a frontend on another server? When trying to call the API on an external server from a script on localhost, I get a CORS error telling me

    Access to fetch at 'http://xxx.xxx.xxx.xxx:8088/dedi/151629' from origin 'http://127.0.0.1:8000' has been blocked by CORS policy: Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response.

    When accessing the API with Postman (or Python), I can see that the server response header for Access-Control-Allow-Headers contains only Content-Type, and not Authorization. Is there a way around this?
     
    • Like Like x 1
  12. ACX_Com

    ACX_Com New Member

    Joined:
    May 18, 2020
    Ratings:
    +2 / 0 / -0
    Hello everybody

    Subject / Problem:
    Automatic loading back-up
    Autostart sessions / games
    Put online automatically

    I've already asked for it here and there, but haven't received any answers yet, maybe it fits here with the API and you can help me.

    I'm running Dedi Server with 5 sessions / games.
    So far everything works fine, but I have the following problem ...

    Since I don't have a fixed WAN-IP and thus get a new WAN-IP every night if the internet is briefly disconnected, the main server at RaceRoom probably loses the info / connection to my Dedi server (my guess).

    That means I have to MANUALLY EVERY DAY ...
    • Restart the server - not the physical or the VM but the server application
    • Import the back-up of the settings
    • start the sessions / games

    I don't have any big requirements, I just want to automate the above - e.g. via the Windows task planning, possibly with batch or something like that.

    Via the API, I only found the option to start / stop the sessions / games, but I can't even do that because (sorry) I don't know anything about json and how I can access json, for example, in batch.
    I had found many websites, but none of them succeeded me.

    How can I do that?
    Can someone recommend some kind of suitable tutorial on how to use json?

    Best regards
    Achim
     
  13. LaundroMat

    LaundroMat Member

    Joined:
    Nov 28, 2020
    Ratings:
    +15 / 0 / -0
    Hi Achim,

    I'm sorry if this isn't a solution to your problem, but if you are currently paying for your server (the machine, that is), have a look at https://dollarracing.club
    I made that to make it easier to launch and run a server. In terms of cost it's less than renting a server for a month at e.g. Vultr and you only pay for what you use. There is no automatic loading of settings yet,but I'll gladly add it if you think that is valuable to you.
     
    • Dislike Dislike x 1
  14. ACX_Com

    ACX_Com New Member

    Joined:
    May 18, 2020
    Ratings:
    +2 / 0 / -0
    Hold back with your constant spam and advertising, when I'm looking for a foreign server, I'm looking for it and not for support!
    Either you can contribute something helpful or please leave it to offer yourself here in the forum to earn money.
    Advertise elsewhere, but not on a forum where help is sought!
     
    • Like Like x 1
  15. ACX_Com

    ACX_Com New Member

    Joined:
    May 18, 2020
    Ratings:
    +2 / 0 / -0
    UPDATE:
    I've solved all the problems except this one:
    • Import the backup of the settings

    That means importing a settings file!
    After I solve that I have a complete solution.

    I don't publish my work because I don't like that users like LaundroMat get solutions, help and a business cost from all of us!


     
  16. LaundroMat

    LaundroMat Member

    Joined:
    Nov 28, 2020
    Ratings:
    +15 / 0 / -0
    Oh! I'm so sorry that I made you feel this way.

    Just to be clear: I'm not trying to make any money out of this. For a full month server time, there's ca. $4 left "for me". That's margin that I keep because: ec2 windows instances are rated by the hour by AWS, meaning that if you have server credits for a month, I actually "pay" more to AWS than what you consume. Add to that the network transfer, the cost of copying AMI's - disk images of a Windows server - across AWS regions, hosting, domain name, S3, mail, testing and (most important of all) the PayPal fee. I'm adding a margin because I don't want to lose money on this.

    I just like making things and working with user feedback to improve stuff. I initially scratched my own itch (automatic server deployment, my network at home is router upon router with variable IP's, meaning I had to go back and configure router ports all the time), found out some people liked the idea, and now I am actively soliciting feedback from people to create something worthwhile.

    Now, if you feel I'm spamming, that's ok with me. I'm eager to get people's responses, that's true. I'm apparently overstepping a line and bothering people, so I'll hold back. Thanks for letting me know I'm getting on your nerves.

    Also, I'm working on automated application of settings, so when I get around to it, I'll let you know how. One tip: run a dedicated server, open up the console window (F12 in Chrome or FF) and look at the network tab.

    Then, upload settings using the web client and you'll see something like this. Click on the line with /dedi in it and you'll see:
    * A POST request was made to the /dedi endpoint
    * with a JSON payload consisting of several objects.
    upload_2021-2-14_15-39-57.png
    Play around with that (I recommend using https://github.com/hoppscotch/hoppscotch or Postman) to see what works and what doesn't.

    What are you using to send your requests by the way? A Python script, curl or anything else?

    I'll gladly help you along and I promise I'll shut up about [redacted].
     

    Attached Files:

  17. ACX_Com

    ACX_Com New Member

    Joined:
    May 18, 2020
    Ratings:
    +2 / 0 / -0
    Hi.
    I don't want to cause an argument, and I didn't mean it to be angry either.
    The reason for my reaction was that you have repeatedly given the same recommendation to join you, but no helpful information that you obviously could give.

    When someone asks for solutions to a problem ...
    E.g. How do I dismantle the wheels from my car and someone writes to go to the workshop is anything but satisfactory for the questioner and absolutely does not help him.

    So everything is good and sponge over it - as it is called in Germany.

    I know how to read the json from the developer area in the browser.
    In the same way today I dealt with json and its transmission / query via PowerSehll.

    So now I'm ready to ...
    • Starting the server software using task scheduling
    • Restoring backups (or individual settings, if I want) in batch
    • Batch deletion of all sessions / games
    • Start all sessions / games in batch

    I only have to control (set up) the batches via task scheduling. no more coming.

    So that no more drivers / players come to the server, shortly (e.g. 30 minutes) before I restart everything, I consider leaving the sessions running, but reading when the session (e.g. the last set race) will end and then first set the servers offline one after the other, etc.

    ... so basically I've done everything important, except for the following major point:
    Do not wait until my router (FritzBox 7590) independently re-establishes the Internet connection at some point (set between 3 a.m. and 4 a.m. at night), but also starts this itself controlled by the server.
     
  18. ACX_Com

    ACX_Com New Member

    Joined:
    May 18, 2020
    Ratings:
    +2 / 0 / -0
    I currently tried and use PowerShell with Invoke-WebRequest / Invoke-RestMethod because I'm not a fan of a lot of extra software, especially not on a server. ;)
     
  19. LaundroMat

    LaundroMat Member

    Joined:
    Nov 28, 2020
    Ratings:
    +15 / 0 / -0
    We have the same sponge-saying in Dutch (I'm from the Dutch speaking part of Belgium) :)

    Your comparison about the tires and workshop is very true: I'll keep that in mind next time and won't let my eagerness interfere. Honestly, thanks for that.

    You got me thinking too. I'll try and start documenting my research into the API for the service I'm building. Maybe I could create a wiki with all the info on the API. This way, the R3E developers have more time to develop and we can all learn from each other.
     
  20. LaundroMat

    LaundroMat Member

    Joined:
    Nov 28, 2020
    Ratings:
    +15 / 0 / -0