Skip to content

backend-url setting gets corrupted somehow #4

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

Closed
HebaruSan opened this issue Feb 16, 2018 · 29 comments
Closed

backend-url setting gets corrupted somehow #4

HebaruSan opened this issue Feb 16, 2018 · 29 comments

Comments

@HebaruSan
Copy link
Contributor

Description (What went wrong?):

OpenDock loads to a large loading animation and stays that way:

image

If I open the dev tools and delete the div containing that graphic, the page content is there but (unsurprisingly) not initialized:

image

Reproduction Steps (What did you do?):

Set these in config.php across different tests:

        'backend-url' => 'http://127.0.0.1:5000/',
        'backend-url' => 'https://127.0.0.1:5000/',

Expected Behavior (What do you think should have happened instead?):

Presumably the loading screen should only be visible for a few seconds or less.

Environment (OS/Browser/Plugins/etc):

  • Ubuntu
  • Chromium

Extra Information (Screenshots/Error Messages/Javascript Console Output):

Several errors show up in the browser console with invalid URLs that are apparent perversions of the configured backend-url. It looks like the first colon is spliced out, and then http:// is added to the beginning:

With http://127.0.0.1:5000/:

image

With https://127.0.0.1:5000/:

image

Maybe the setting isn't actually supposed to be a URL?

@Xinayder
Copy link
Contributor

You don't need the protocol in the backend-url config field.

@HebaruSan
Copy link
Contributor Author

Removing the protocol gives me this:

        'backend-url' => '127.0.0.1:5000/',

image

I assume the double slashes are the culprit. I'd suggest renaming this setting to backend-host since it does not work with URLs.

@StollD
Copy link
Member

StollD commented Feb 16, 2018

OpenDock used to prefix the value from backend-url with // automatically (so it should use the same protocol the site itself used).

I changed it to detect if it is prefixed with http:// or https:// and if thats the case, use the protocol specified by the user, otherwise use the one the site uses.

999fdce

@HebaruSan
Copy link
Contributor Author

That looks like a fix to me. Thanks!

@HebaruSan
Copy link
Contributor Author

Is it possible to bootstrap from an empty database? My backend seems to be returning nothing for these four calls, and I was expecting that I could start from nothing, register the first user, upload the first mod, etc. However, an exception is thrown because browse.data is undefined:

image

The code where this exception is thrown:

'browse': {
'featured': browse.data.featured,
'top': browse.data.top,
'updated': browse.data.updated,
'new': browse.data.new,
'yours': browse.data.yours
},

I can't tell whether the front end should be more prepared for this possibility, or if the backend should be returning something.

@Xinayder
Copy link
Contributor

If I recall correctly, you need to install some plugins, more specifically adapter, search and transformers.

@StollD
Copy link
Member

StollD commented Feb 16, 2018

The backend has it's own command for that, it can setup the database with the data that is required to use it.

usage: sdb setup [-dummy=true|false]

The setup subcommand will add an administrator account, a normal user,
publisher, game, game admin and some dummy mods to the database.

If you set the dummy flag to false, only an admin account will be added.

This is mainly used to populate internal data (like the various permissions).

Also, the request fails because you try to browse the mods for a game with the gameshort KSP, since your database is empty, the game isn't found and the backend returns a 404 error message. The dummy data that is added by sdb setup uses kerbal-space-program as the short name (the same that SpaceDock uses).

OpenDock currently requires that one game is added to the database, #2 tries to change that, but I didn't have the time to finish it properly.

@HebaruSan
Copy link
Contributor Author

But that's a long name. :(

Hmm, I did run sdb setup, both before and after installing the plugins. Does it run differently with plugins installed?

@StollD
Copy link
Member

StollD commented Feb 16, 2018

It shouldn't. Maybe it is simply the KSP vs. kerbal-space-program issue.

@HebaruSan
Copy link
Contributor Author

Similar result with kerbal-space-program:

image

@HebaruSan
Copy link
Contributor Author

Trying http://127.0.0.1:5000/api/users/current in a browser says:

{"codes":[1035],"error":true,"reasons":["You need to be logged in to access this page"]}

... which seems like a reasonable enough response. It's true that I'm not logged in, and it makes sense to hide certain info from anonymous users.

@StollD
Copy link
Member

StollD commented Feb 16, 2018

OpenDock expects that response and deals with it. However, since the browse stuff is what is failing (and it isn't limited to logged in users), could you post the response of /api/games please?

@HebaruSan
Copy link
Contributor Author

That returns the empty string, or as my browser puts it:

This page isn’t working
127.0.0.1 didn’t send any data.
ERR_EMPTY_RESPONSE

@StollD
Copy link
Member

StollD commented Feb 16, 2018

Thats really confusing, it should at least return an empty array.

My last idea would be to delete and recreate the database completely, but I am unsure how much that would actually help

@Xinayder
Copy link
Contributor

What about your database, is it populated?

@StollD
Copy link
Member

StollD commented Feb 16, 2018

He said he ran sdb setup two times, so I would assume it is.

@HebaruSan
Copy link
Contributor Author

Yeah, if there's some way of independently verifying that sdb setup worked, I'll happily try it, but for now I'm assuming it worked.

@StollD
Copy link
Member

StollD commented Feb 16, 2018

Well, you could open the database and check if there is something inside of the tables. Or you could export it to an .sql file and upload it, so we can check.

@HebaruSan
Copy link
Contributor Author

OK, here's some psql command line. I'll prune the tables that don't seem related...

SELECT * FROM pg_catalog.pg_tables ORDER BY tableowner;

     schemaname     |        tablename        | tableowner | tablespace | hasindexes | hasrules | hastriggers | rowsecurity 
--------------------+-------------------------+------------+------------+------------+----------+-------------+-------------
 public             | abilities               | spacedock  |            | t          | f        | f           | f
 public             | download_events         | spacedock  |            | t          | f        | f           | f
 public             | follow_events           | spacedock  |            | t          | f        | f           | f
 public             | referral_events         | spacedock  |            | t          | f        | f           | f
 public             | featureds               | spacedock  |            | t          | f        | f           | f
 public             | games                   | spacedock  |            | t          | f        | f           | f
 public             | shared_authors          | spacedock  |            | t          | f        | f           | f
 public             | tokens                  | spacedock  |            | t          | f        | f           | f
 public             | game_versions           | spacedock  |            | t          | f        | f           | f
 public             | mod_followers           | spacedock  |            | t          | f        | f           | f
 public             | role_abilities          | spacedock  |            | t          | f        | f           | f
 public             | mods                    | spacedock  |            | t          | f        | f           | f
 public             | mod_lists               | spacedock  |            | t          | f        | f           | f
 public             | mod_list_items          | spacedock  |            | t          | f        | f           | f
 public             | mod_versions            | spacedock  |            | t          | f        | f           | f
 public             | publishers              | spacedock  |            | t          | f        | f           | f
 public             | ratings                 | spacedock  |            | t          | f        | f           | f
 public             | role_users              | spacedock  |            | t          | f        | f           | f
 public             | roles                   | spacedock  |            | t          | f        | f           | f
 public             | users                   | spacedock  |            | t          | f        | f           | f
spacedockbackend=> select * from games;
 id |          created_at           |          updated_at           | deleted_at | meta |         name         | active | altname | rating |          releasedate          |        short         | publisher_id | description | short_description 
----+-------------------------------+-------------------------------+------------+------+----------------------+--------+---------+--------+-------------------------------+----------------------+--------------+-------------+-------------------
  2 | 2018-02-15 21:55:44.274209-06 | 2018-02-15 21:55:44.275501-06 |            | {}   | Factorio             | t      |         |      0 | 2018-02-15 21:55:44.274091-06 | factorio             |            2 |             | 
  1 | 2018-02-15 21:55:44.268473-06 | 2018-02-15 21:56:03.887121-06 |            | {}   | Kerbal Space Program | t      |         |      0 | 2018-02-15 21:55:44.268388-06 | kerbal-space-program |            1 |             | 
(2 rows)

@Xinayder
Copy link
Contributor

Xinayder commented Feb 16, 2018

Were you running the backend when you queried /api/games?

EDIT: if it doesn't work, try adding a trailing slash, e.g. /api/games/

@HebaruSan
Copy link
Contributor Author

Yup. If I wasn't, nothing would have been listening on that port, so it would have said "The site can't be reached"/ERR_CONNECTION_REFUSED instead.

image

@Xinayder
Copy link
Contributor

Can you screenshot the error that is being thrown by sdb?

@HebaruSan
Copy link
Contributor Author

sdb isn't raising errors. The terminal in that screenshot shows sdb while the page is refreshed.

Sorry, something went wrong.

@StollD
Copy link
Member

StollD commented Feb 16, 2018

Thats a go stacktrace, so something is going terribly wrong there. So not really a user error, but an exception thrown by the code.

Normally it shouldn't show those :D

Sorry, something went wrong.

@HebaruSan
Copy link
Contributor Author

Aha! I guess that "redis" thing is required after all, going by the port number?

2018/02/16 15:51:40 http: panic serving 127.0.0.1:58344: dial tcp [::1]:6379: getsockopt: connection refused
goroutine 1108 [running]:

Sorry, I didn't know what that was. I'll go look it up...

Sorry, something went wrong.

@StollD
Copy link
Member

StollD commented Feb 16, 2018

Change store-type: "redis" to store-type: "memory" in your config.yml, then it shouldn't try to use redis.

@HebaruSan
Copy link
Contributor Author

That was definitely it!!

{"count":2,"data":[{"active":true,"altname":"","created":"2018-02-15T21:55:44.274209-06:00","description":"","id":2,"meta":{},"name":"Factorio","publisher":2,"rating":0,"releasedate":"2018-02-15T21:55:44.274091-06:00","short":"factorio","short_description":"","updated":"2018-02-15T21:55:44.275501-06:00"},{"active":true,"altname":"","created":"2018-02-15T21:55:44.268473-06:00","description":"","id":1,"meta":{},"name":"Kerbal Space Program","publisher":1,"rating":0,"releasedate":"2018-02-15T21:55:44.268388-06:00","short":"kerbal-space-program","short_description":"","updated":"2018-02-15T21:56:03.887121-06:00"}],"error":false}

image

@HebaruSan
Copy link
Contributor Author

And after installing redis-server, using redis seems to work as well.

If it's OK with you, I'd like to use my notes from this to make the README more idiot-proof. I think I hit most of the stumbling blocks that a new person is likely to encounter.

@StollD
Copy link
Member

StollD commented Feb 16, 2018

I would love that! It's always terribly hard to write a README if you wrote the program too, because you don't know which things might be obvious, and which are hard to spot.

HebaruSan added a commit to HebaruSan/OpenDock that referenced this issue Feb 17, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@HebaruSan HebaruSan mentioned this issue Feb 17, 2018
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

3 participants