Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newly created challenges via API automatically removed #2725

Closed
adamreisnz opened this issue Jun 23, 2024 · 8 comments
Closed

Newly created challenges via API automatically removed #2725

adamreisnz opened this issue Jun 23, 2024 · 8 comments

Comments

@adamreisnz
Copy link

adamreisnz commented Jun 23, 2024

Describe the bug
Creating a new challenge using the API endpoint POST /api/v1/challenges successfully creates a challenge but automatically removes it from the list after ~5 seconds

To Reproduce
Steps to reproduce the behavior:

  1. Create a new challenge using the API to POST /api/v1/challenges
  2. Use the JSON as per below
  3. Observe that the challenge appears in the list on https://beta.online-go.com/play
  4. Wait 5 seconds or so
  5. Observe that the challenge automatically disappears

JSON used:

{
    "initialized": false,
    "min_ranking": -1000,
    "max_ranking": 1000,
    "challenger_color": "random",
    "rengo_auto_start": 0,
    "game": {
        "name": "Test challenge",
        "rules": "japanese",
        "ranked": true,
        "width": 19,
        "height": 19,
        "handicap": -1,
        "komi_auto": "automatic",
        "komi": null,
        "disable_analysis": false,
        "initial_state": null,
        "private": false,
        "rengo": false,
        "rengo_casual_mode": true,
        "time_control": "byoyomi",
        "time_control_parameters": {
            "main_time": 900,
            "period_time": 30,
            "periods": 5,
            "periods_min": 1,
            "periods_max": 300,
            "pause_on_weekends": false,
            "speed": "live",
            "system": "byoyomi",
            "time_control": "byoyomi"
        },
        "pause_on_weekends": false
    }
}

Expected behavior
The challenge remains in the list until removed

Desktop (please complete the following information):
n/a

Smartphone (please complete the following information):
n/a

Additional context
Tested using https://beta.online-go.com
The exact same challenges created via the UI remains in the list indefinitely until cancelled.

@adamreisnz adamreisnz changed the title Newly created challenges automatically disappearing Newly created challenges via API automatically disappearing Jun 23, 2024
@adamreisnz adamreisnz changed the title Newly created challenges via API automatically disappearing Newly created challenges via API automatically removed Jun 23, 2024
@anoek
Copy link
Member

anoek commented Jun 23, 2024

For live games you need to maintain a connection with the websocket, without that the server reasons your browser has gone away and will remove the live challenge.

For correspondence games that's wot the case.

@anoek anoek closed this as completed Jun 23, 2024
@anoek
Copy link
Member

anoek commented Jun 23, 2024

In specific you'll need to mimic what the official client does for keeping challenges alive: https://github.com/online-go/online-go.com/blob/devel/src/components/ChallengeModal/ChallengeModal.tsx#L715

@adamreisnz
Copy link
Author

adamreisnz commented Jun 23, 2024

I'm creating a challenge via the API, this doesn't use web socket connections?

E.g. I'm intending to use these methods for game management/control: https://ogs.docs.apiary.io/#reference/games/game-movement/make-a-move-in-a-game

Where can I find documentation about the socket implementation?

@anoek
Copy link
Member

anoek commented Jun 23, 2024

You'll need to use the websocket protocol for any game playing (and live challenge keep alives)

If you're going to roll your own websocket implementation https://docs.online-go.com/goban/modules/protocol.html is probably a good start. https://github.com/online-go/goban/tree/main/src/engine/protocol for the typescript defs themselves.

@adamreisnz
Copy link
Author

Thanks, I'll have a look into those.

Does the socket protocol still require an oauth application to be registered etc? Does it use the same authentication mechanism as the API with access tokens?

@anoek
Copy link
Member

anoek commented Jun 23, 2024

You get a jwt from your oauth process and pass that in as part of the authentication process for the websocket

@adamreisnz
Copy link
Author

The token I got from the OAuth process doesn't look like a JWT, it's just a short 30 character random string.
Is there a different OAuth endpoint which issues JWT tokens?

@anoek
Copy link
Member

anoek commented Jun 23, 2024

mm, yeah not the oauth, from the https://online-go.com/api/v1/ui/config that you would get after you're authenticated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants