Search Unity

Need help with scoped registries

Discussion in 'Package Manager' started by zheck, May 7, 2019.

  1. zheck

    zheck

    Joined:
    Oct 30, 2018
    Posts:
    6
    I recently gave scoped registries a shot by using Verdaccio. Everything went pretty smoothly, my server is listening to 0.0.0.0:4873 and I can visit my computer's IP / host name with that port from any other PC on my network and see the Verdaccio server and all of the packages it is hosting.

    My problem is that in my manifest.json when I add the scoped registry and set my url to my ip:4873, the packages will not appear. If I set the url to localhost:4873, they show up.

    I've double checked and the IP is not wrong. I can paste it into my browser and the Verdaccio server appears just fine. The packages in my scoped registry will not appear in UPM when I add the scoped registry to my manifest.json on both my local PC and a separate PC on the same network.

    Anyone have any clues as to what is going on?
     
  2. DanielTG

    DanielTG

    Unity Technologies

    Joined:
    Feb 15, 2018
    Posts:
    91
    0.0.0.0 should not be considered a valid IP address. A localhost IP address should default to 127.0.0.1. Not sure why verdaccio is listening on 0.0.0.0 but please give 127.0.0.1 a try if you don’t want to use “localhost”.

    Thanks
    Daniel
     
  3. zheck

    zheck

    Joined:
    Oct 30, 2018
    Posts:
    6
    Hi Daniel,

    In my verdaccio server's config.yaml it is using...

    listen:
    0.0.0.0:4873

    This is (according to their documentation) how to open the server up to be seen by anyone on my network.

    listen:
    # - localhost:4873 # default value
    # - http://localhost:4873 # same thing
    0.0.0.0:4873 # listen on all addresses (INADDR_ANY)
    # - https://example.org:4873 # if you want to use https
    # - "[::1]:4873" # ipv6
    # - unix:/tmp/verdaccio.sock # unix socket

    The problem is that I would like to see this server from other computers, not just my own. I cannot use localhost for this because then no one else would see me.

    Edit : To be more clear, in my manifest.json I am directing the scoped url to my IP, not 0.0.0.0.
     
  4. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    144
    Hi @zheck,

    As far as I can see, your setup seems fine. I've tried the same setup locally and can successfully list and manage packages hosted on my Verdaccio registry. I used the same "listen" config (0.0.0.0:4873) and the scoped registry URL was set to "http://<my-ip>:4873" and it worked. (Note: I tried with the private IP on my network, not my public IP.)

    Do you get error messages in the Editor.log or upm.log files?
     
  5. DanielTG

    DanielTG

    Unity Technologies

    Joined:
    Feb 15, 2018
    Posts:
    91
    Hi @zheck

    Thanks for the extra details. Sorry, I misunderstood what you wrote in your original post. To add to @maximeb_unity reply and to help rule out network timeouts in the Package Manager UI can you please try the following

    A) manually add a package to your project manifest from the verdaccio registry to see if it loads correctly

    B) Assuming verdaccio supports this as well), narrow the subnet mask to listen on (e.g. 255.255.255.0)

    Thanks
    Daniel
     
  6. zheck

    zheck

    Joined:
    Oct 30, 2018
    Posts:
    6
    Hi guys,

    @maximeb_unity It sounds like based on your success that it would be something on my work network blocking this from happening. There are no logs, unfortunately. The best I can get is that if I set my scoped url in my manifest.json to localhost (127.0.0.1) I can see the packages and successfully install them. Once I install one I then go back to my manifest.json and edit the scoped url to my private network IP. Here it gives me an error message about the package that I just installed..

    "Failed to fetch versions information: Request 'http://<my-ip>:4873/com.my.package' failed with status code [502]"

    Do you have any idea what that error code is?

    @DanielTG No worries, thank you for your help!

    A) I am able to add a package from verdaccio if I use localhost (127.0.0.1) as my manifest.json's scoped url. It doesn't seem to have any timeout issues.

    B) I'm unsure what you mean, sorry!
     
  7. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    144
    @zheck Ah, the 502 ("Bad Gateway") error seems to indicate that this is an error reported by Verdaccio, maybe when it tries to act as a proxy. 502 is typically returned by a server (or service) when an operation failed because it acted as a tunnel to another server, and that server could not be reached. Alternatively it might be because some firewall on your computer is intervening and somehow unable to forward the request to Verdaccio itself.

    Just in case, if you only intended to use it as a standalone registry, make sure you adjust its configuration to disable proxying. By default, Verdaccio will act as a proxy to the npmjs.org registry, which is not desirable here since npm packages are not Unity packages.
     
  8. zheck

    zheck

    Joined:
    Oct 30, 2018
    Posts:
    6
    @maximeb_unity I'm not sure if I'm properly disabling my server's proxy, and I apologize if you don't know and I'm asking too much but if you do know that'd be some really helpful clarification!

    Here is what I've tried, so far to no avail...
    • tried adding no_proxy: localhost,127.0.0.1 to my config.yaml
    • tried specifying the http and https proxies in config.yaml as defined by my PC's environment variables (HTTP_PROXY and HTTPS_PROXY)
    I figured if no_proxy wasn't working that if I direct it to my network's proper proxy it might? I'm sort of just grasping at straws. I think based on our conversation it's clear that my issue comes down to a network permissions issue. I'll continue to play with my settings and confirm that this works properly at home where I will be in control of all of my network settings.

    To be honest I have only just recently learned what npm even is lol. It has just never been a part of my work environment. That being said, feel free to shoot me "restart your router" type suggestions if you've got them.

    Edit : I should also be clear that the 502 Bad Gateway is only coming about after a successful install via localhost, and then UPM attempting to populate itself with packages from my scoped registry when I set the scoped url to my actual IP (instead of localhost.) I suspect that if I set the scoped url to something ridiculous like 1.2.3.4:1234 it would give me the same bad gateway.
     
  9. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    144
    Hi @zheck

    Investigating your proxy settings is definitely a good place to start. The config.yaml file is the Verdaccio config, right? If so, then it might not help since these variables need to be set for the client from where call originates - in this case, the Package Manager. Since it's a child process of the Unity Editor, itself presumably a child process of the Hub, you may need to configure either the Editor or the Hub with those variables.

    You could try setting "no_proxy" to "localhost,127.0.0.1,<your-network-ip>" (note: above, you only listed the first two). This should disable proxy support from requests targeting these hosts.

    I doubt it. If you put an invalid URL then it simply won't get a sensical error. 502 actually is meaningful - unfortunately, we just don't know who is returning it, and why :D

    Did you check in your Editor.log and upm.log to see if you found additional information which could be helpful? (The upm.log is generated next to the Editor.log.)
     
  10. zheck

    zheck

    Joined:
    Oct 30, 2018
    Posts:
    6
    Hi @maximeb_unity

    Looks like adding my network IP to the no_proxy environment variable is what was missing! I think my "gotcha" here was that I wasn't restarting Unity whenever I changed environment variables, but once I did everything worked fine.

    Thanks again for yours and @DanielTG for helping me, and thank you for adding this feature! It is very, very useful!
     
    maximeb_unity likes this.