Jump to content

Question

Posted

Hello,

 

Im looking at the documentation for the API and want to test it.

I have granted my user the correct roles.

I have enabled the API.

 

The server is currently running from another computer in my home and is public.

Currently says that the API listening on "HTTP://localhost:5400"

8857047f630f11c77ecb6f34d22ef399.png

c0d5925b42eab52c5229985ff3f3ff2f.png

 

How do I access the API from another computer within the same network and from external network?

 

I have tried using postman sending the following from the same network on another computer but I get error 400.

b47836bed3e36eda35d387e473c6169b.png

 

 

18 answers to this question

Recommended Posts

  • 0
Posted
24 minutes ago, Jcsnider2 said:

In the Server/Resourcs/config/api.config.json change http://localhost:5400 to http://*:5400 and it will accept connections outside of localhost I believe.

 

Edit: Forgive the dummy account, I'm working on a project that links accounts with AGD lol

 

74ff3640738409bbc3bc96f10dd3c636.png

 

It didn't work, is there any other way?
  _____       _                          _
 |_   _|     | |                        | |
   | |  _ __ | |_ ___ _ __ ___  ___  ___| |_
   | | | '_ \| __/ _ \ '__/ __|/ _ \/ __| __|
  _| |_| | | | ||  __/ |  \__ \  __/ (__| |_
 |_____|_| |_|\__\___|_|  |___/\___|\___|\__|
                          free 2d orpg engine
Copyright (C) 2019 Ascension Game Dev
Version 0.6.0.0
For help, support, and updates visit: https://www.ascensiongamedev.com
Loading, please wait.

Server has 7 registered players.
Game time is now: Thursday, September 12, 2019 1:22:27 PM

Server Started. Using UDP Port #5400


Failed to start API.
2019-09-12 18:15:01.033 [Error] Failed to start API.
System.Reflection.TargetInvocationException: Ett undantagsfel har inträffat i målet för en aktivering. ---> System.Net.HttpListenerException: Åtkomst nekad
   vid System.Net.HttpListener.AddAllPrefixes()
   vid System.Net.HttpListener.Start()
   vid Microsoft.Owin.Host.HttpListener.OwinHttpListener.Start(HttpListener listener, Func`2 appFunc, IList`1 addresses, IDictionary`2 capabilities, Func`2 loggerFactory)
   vid Microsoft.Owin.Host.HttpListener.OwinServerFactory.Create(Func`2 app, IDictionary`2 properties)
   --- Slut på stackspårning för interna undantag ---
   vid System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   vid System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   vid System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   vid Microsoft.Owin.Hosting.ServerFactory.ServerFactoryAdapter.Create(IAppBuilder builder)
   vid Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context)
   vid Intersect.Server.Web.RestApi.RestApi.Start() i C:\Users\JC Snider\Desktop\AGD\Intersect-Engine\Intersect.Server\Web\RestApi\RestApi.cs:rad 71


Connection Information:
   Public IP: XXX.XX.XXX.XXX
   Public Port: 5400

Your game is accesible to the public!
Enter your public ip and port into the client/editor config for others to join!

Type exit to shutdown the server, or help for a list of commands.
>

  • 0
Posted
8 minutes ago, Jcsnider2 said:

Try right clicking on the server and running as admin.

 

I tried to run that as Admin but then the whole Server just starts and then crashes. I run this on Windows 10

 

 

Logs

 

Spoiler

2019-09-12 18:32:45.827 [Error] 
  Message: Ogiltig URI. Den gick inte att parsa värdnamnet.
    Stack:    vid System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   vid Intersect.Server.Web.RestApi.Configuration.ApiConfiguration.<>c.<get_Ports>b__7_0(String host) i C:\Users\JC Snider\Desktop\AGD\Intersect-Engine\Intersect.Server\Web\RestApi\Configuration\ApiConfiguration.cs:rad 48
   vid System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   vid System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   vid System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   vid System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
   vid Intersect.Server.Web.RestApi.Configuration.ApiConfiguration.get_Ports() i C:\Users\JC Snider\Desktop\AGD\Intersect-Engine\Intersect.Server\Web\RestApi\Configuration\ApiConfiguration.cs:rad 48
   vid Intersect.Server.Core.ServerContext.InternalStartNetworking() i C:\Users\JC Snider\Desktop\AGD\Intersect-Engine\Intersect.Server\Core\ServerContext.cs:rad 139
   vid Intersect.Server.Core.ServerContext.InternalStart() i C:\Users\JC Snider\Desktop\AGD\Intersect-Engine\Intersect.Server\Core\ServerContext.cs:rad 158


--------------------------------------------------------------------------------
2019-09-12 18:32:46.014 [Error] Received unhandled exception from .

--------------------------------------------------------------------------------
2019-09-12 18:32:46.022 [Error] 
  Message: Ogiltig URI. Den gick inte att parsa värdnamnet.
    Stack:    vid System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   vid Intersect.Server.Web.RestApi.Configuration.ApiConfiguration.<>c.<get_Ports>b__7_0(String host) i C:\Users\JC Snider\Desktop\AGD\Intersect-Engine\Intersect.Server\Web\RestApi\Configuration\ApiConfiguration.cs:rad 48
   vid System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   vid System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   vid System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   vid System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
   vid Intersect.Server.Web.RestApi.Configuration.ApiConfiguration.get_Ports() i C:\Users\JC Snider\Desktop\AGD\Intersect-Engine\Intersect.Server\Web\RestApi\Configuration\ApiConfiguration.cs:rad 48
   vid Intersect.Server.Core.ServerContext.InternalStartNetworking() i C:\Users\JC Snider\Desktop\AGD\Intersect-Engine\Intersect.Server\Core\ServerContext.cs:rad 139
   vid Intersect.Server.Core.ServerContext.InternalStart() i C:\Users\JC Snider\Desktop\AGD\Intersect-Engine\Intersect.Server\Core\ServerContext.cs:rad 171
   vid Intersect.Core.ApplicationContext`1.Start(Boolean lockUntilShutdown) i C:\Users\JC Snider\Desktop\AGD\Intersect-Engine\Intersect (Core)\Core\ApplicationContext.cs:rad 63
   vid Intersect.Core.ApplicationContext`1.StartWithActionQueue() i C:\Users\JC Snider\Desktop\AGD\Intersect-Engine\Intersect (Core)\Core\ApplicationContext.cs:rad 81
   vid Intersect.Server.Core.Bootstrapper.Start(String[] args) i C:\Users\JC Snider\Desktop\AGD\Intersect-Engine\Intersect.Server\Core\Bootstrapper.cs:rad 49


--------------------------------------------------------------------------------
 

 

  • 0
Posted
20 hours ago, jcsnider said:

Do:

http://[public-ip-here]:5400

 

Instead.

 

I tried both public and internal IP. The server starts and then just crashes with the same logs as if run as admin.

Do you think I have any fault with router settings, and or windows 10?

is there any other tests I can do and provide with results?

 

Listening on 0.0.0.0:5400.

--------------------------------------------------------------------------------
UPnP Service Initialization Succeeded

--------------------------------------------------------------------------------
Successfully auto port forwarded udp port 5400 using UPnP.

--------------------------------------------------------------------------------
2019-09-13 15:54:15.242 [Error] 
  Message: Invalid URI: The hostname could not be parsed.
    Stack:   at System.Uri.CreateThis (System.String uri, System.Boolean dontEscape, System.UriKind uriKind) [0x0007b] in <118907f5eb5f4e538f3e3bdd8361378f>:0 
  at System.Uri..ctor (System.String uriString) [0x00014] in <118907f5eb5f4e538f3e3bdd8361378f>:0 
  at Intersect.Server.Web.RestApi.Configuration.ApiConfiguration+<>c.<get_Ports>b__7_0 (System.String host) [0x00005] in <c9507855f5e44870b9975eb763bbcbda>:0 
  at System.Linq.Enumerable+SelectArrayIterator`2[TSource,TResult].ToArray () [0x00012] in <28b7381f9e304c3eae9fa66907f89854>:0 
  at System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0001f] in <28b7381f9e304c3eae9fa66907f89854>:0 
  at System.Collections.Immutable.ImmutableArray.CreateRange[T] (System.Collections.Generic.IEnumerable`1[T] items) [0x0004d] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at System.Collections.Immutable.ImmutableArray.ToImmutableArray[TSource] (System.Collections.Generic.IEnumerable`1[T] items) [0x0000f] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at Intersect.Server.Web.RestApi.Configuration.ApiConfiguration.get_Ports () [0x0002a] in <c9507855f5e44870b9975eb763bbcbda>:0 
  at Intersect.Server.Core.ServerContext.InternalStartNetworking () [0x000be] in <c9507855f5e44870b9975eb763bbcbda>:0 
  at Intersect.Server.Core.ServerContext.InternalStart () [0x00002] in <c9507855f5e44870b9975eb763bbcbda>:0 


--------------------------------------------------------------------------------
2019-09-13 15:54:15.245 [Info] Acquiring context lock... (0ms)

--------------------------------------------------------------------------------
2019-09-13 15:54:15.245 [Info] Acquired. (0ms)

--------------------------------------------------------------------------------
2019-09-13 15:54:15.245 [Info] Beginning context dispose. (0ms)

--------------------------------------------------------------------------------
2019-09-13 15:54:15.246 [Info] Disposing network... (0ms)

--------------------------------------------------------------------------------
2019-09-13 15:54:15.249 [Info] Saving player database... (2ms)

--------------------------------------------------------------------------------
2019-09-13 15:54:15.249 [Info] Saving game database... (3ms)

--------------------------------------------------------------------------------
2019-09-13 15:54:15.324 [Info] Shutting down the API... (78ms)

--------------------------------------------------------------------------------
2019-09-13 15:54:15.331 [Info] Base dispose. (85ms)

--------------------------------------------------------------------------------
2019-09-13 15:54:15.331 [Info] Finished disposing server context. (85ms)

--------------------------------------------------------------------------------
2019-09-13 15:54:15.331 [Info] GC.SuppressFinalize (85ms)

--------------------------------------------------------------------------------
2019-09-13 15:54:15.331 [Info] InternalDispose() completed. (85ms)

--------------------------------------------------------------------------------
2019-09-13 15:54:15.331 [Info] Clearing instance... (86ms)

--------------------------------------------------------------------------------
2019-09-13 15:54:15.332 [Info] Releasing context lock... (86ms)

--------------------------------------------------------------------------------
2019-09-13 15:54:15.332 [Info] Released. (86ms)

--------------------------------------------------------------------------------
2019-09-13 15:54:15.333 [Error] Received unhandled exception from .

--------------------------------------------------------------------------------
2019-09-13 15:54:15.333 [Error] 
  Message: Invalid URI: The hostname could not be parsed.
    Stack:   at System.Uri.CreateThis (System.String uri, System.Boolean dontEscape, System.UriKind uriKind) [0x0007b] in <118907f5eb5f4e538f3e3bdd8361378f>:0 
  at System.Uri..ctor (System.String uriString) [0x00014] in <118907f5eb5f4e538f3e3bdd8361378f>:0 
  at Intersect.Server.Web.RestApi.Configuration.ApiConfiguration+<>c.<get_Ports>b__7_0 (System.String host) [0x00005] in <c9507855f5e44870b9975eb763bbcbda>:0 
  at System.Linq.Enumerable+SelectArrayIterator`2[TSource,TResult].ToArray () [0x00012] in <28b7381f9e304c3eae9fa66907f89854>:0 
  at System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0001f] in <28b7381f9e304c3eae9fa66907f89854>:0 
  at System.Collections.Immutable.ImmutableArray.CreateRange[T] (System.Collections.Generic.IEnumerable`1[T] items) [0x0004d] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at System.Collections.Immutable.ImmutableArray.ToImmutableArray[TSource] (System.Collections.Generic.IEnumerable`1[T] items) [0x0000f] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at Intersect.Server.Web.RestApi.Configuration.ApiConfiguration.get_Ports () [0x0002a] in <c9507855f5e44870b9975eb763bbcbda>:0 
  at Intersect.Server.Core.ServerContext.InternalStartNetworking () [0x000be] in <c9507855f5e44870b9975eb763bbcbda>:0 
  at Intersect.Server.Core.ServerContext.InternalStart () [0x00055] in <c9507855f5e44870b9975eb763bbcbda>:0 
  at Intersect.Core.ApplicationContext`1[TContext].Start (System.Boolean lockUntilShutdown) [0x00011] in <961f5c104a8f4d5d8805ed6ff1f7516f>:0 
  at Intersect.Core.ApplicationContext`1[TContext].StartWithActionQueue () [0x00001] in <961f5c104a8f4d5d8805ed6ff1f7516f>:0 
  at Intersect.Server.Core.Bootstrapper.Start (System.String[] args) [0x00038] in <c9507855f5e44870b9975eb763bbcbda>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0003b] in <b4d1a66727f44ba888b54966284fabb4>:0 


--------------------------------------------------------------------------------
 

2019-09-13 15:54:15.242 [Error] 
  Message: Invalid URI: The hostname could not be parsed.
    Stack:   at System.Uri.CreateThis (System.String uri, System.Boolean dontEscape, System.UriKind uriKind) [0x0007b] in <118907f5eb5f4e538f3e3bdd8361378f>:0 
  at System.Uri..ctor (System.String uriString) [0x00014] in <118907f5eb5f4e538f3e3bdd8361378f>:0 
  at Intersect.Server.Web.RestApi.Configuration.ApiConfiguration+<>c.<get_Ports>b__7_0 (System.String host) [0x00005] in <c9507855f5e44870b9975eb763bbcbda>:0 
  at System.Linq.Enumerable+SelectArrayIterator`2[TSource,TResult].ToArray () [0x00012] in <28b7381f9e304c3eae9fa66907f89854>:0 
  at System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0001f] in <28b7381f9e304c3eae9fa66907f89854>:0 
  at System.Collections.Immutable.ImmutableArray.CreateRange[T] (System.Collections.Generic.IEnumerable`1[T] items) [0x0004d] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at System.Collections.Immutable.ImmutableArray.ToImmutableArray[TSource] (System.Collections.Generic.IEnumerable`1[T] items) [0x0000f] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at Intersect.Server.Web.RestApi.Configuration.ApiConfiguration.get_Ports () [0x0002a] in <c9507855f5e44870b9975eb763bbcbda>:0 
  at Intersect.Server.Core.ServerContext.InternalStartNetworking () [0x000be] in <c9507855f5e44870b9975eb763bbcbda>:0 
  at Intersect.Server.Core.ServerContext.InternalStart () [0x00002] in <c9507855f5e44870b9975eb763bbcbda>:0 


--------------------------------------------------------------------------------
2019-09-13 15:54:15.333 [Error] Received unhandled exception from .

--------------------------------------------------------------------------------
2019-09-13 15:54:15.334 [Error] 
  Message: Invalid URI: The hostname could not be parsed.
    Stack:   at System.Uri.CreateThis (System.String uri, System.Boolean dontEscape, System.UriKind uriKind) [0x0007b] in <118907f5eb5f4e538f3e3bdd8361378f>:0 
  at System.Uri..ctor (System.String uriString) [0x00014] in <118907f5eb5f4e538f3e3bdd8361378f>:0 
  at Intersect.Server.Web.RestApi.Configuration.ApiConfiguration+<>c.<get_Ports>b__7_0 (System.String host) [0x00005] in <c9507855f5e44870b9975eb763bbcbda>:0 
  at System.Linq.Enumerable+SelectArrayIterator`2[TSource,TResult].ToArray () [0x00012] in <28b7381f9e304c3eae9fa66907f89854>:0 
  at System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0001f] in <28b7381f9e304c3eae9fa66907f89854>:0 
  at System.Collections.Immutable.ImmutableArray.CreateRange[T] (System.Collections.Generic.IEnumerable`1[T] items) [0x0004d] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at System.Collections.Immutable.ImmutableArray.ToImmutableArray[TSource] (System.Collections.Generic.IEnumerable`1[T] items) [0x0000f] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at Intersect.Server.Web.RestApi.Configuration.ApiConfiguration.get_Ports () [0x0002a] in <c9507855f5e44870b9975eb763bbcbda>:0 
  at Intersect.Server.Core.ServerContext.InternalStartNetworking () [0x000be] in <c9507855f5e44870b9975eb763bbcbda>:0 
  at Intersect.Server.Core.ServerContext.InternalStart () [0x00055] in <c9507855f5e44870b9975eb763bbcbda>:0 
  at Intersect.Core.ApplicationContext`1[TContext].Start (System.Boolean lockUntilShutdown) [0x00011] in <961f5c104a8f4d5d8805ed6ff1f7516f>:0 
  at Intersect.Core.ApplicationContext`1[TContext].StartWithActionQueue () [0x00001] in <961f5c104a8f4d5d8805ed6ff1f7516f>:0 
  at Intersect.Server.Core.Bootstrapper.Start (System.String[] args) [0x00038] in <c9507855f5e44870b9975eb763bbcbda>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0003b] in <b4d1a66727f44ba888b54966284fabb4>:0 


--------------------------------------------------------------------------------
 

 

  • 0
Posted
11 minutes ago, jcsnider said:

Share your api.config.json

{
  "RouteAuthorization": {},
  "Hosts": [
    "http://213.67.202.187:5400"
  ],
  "Cors": [],
  "DataProtectionKey": "CE5DAD93C76EF62BB8259D0866D20B476632731979B3BCFD9F00FDAE03852FE1",
  "Enabled": true,
  "DebugMode": false,
  "SeedMode": false,
  "RefreshTokenLifetime": 15
}

 

f19c4778f1ebd574e223130016403221.png

 

When I use localhost:5400 I can connect to the API on the current machine but not from another machine

  • 0
Posted
8 minutes ago, jcsnider said:

Can confirm it's a bug at this point...

 

If you set the config back to default:

http://localhost:5400/

 

And then launch the server using the parameter:

--apiport=5400

 

Via a terminal does it work?

e11745956a3b412ba446c731bbb7e978.png

 

Seems to work with --apiport=5400

Check the following picture as the API is listening on http://*:5400

I'll test to start the server on another computer and try to access the API from this Mac and report back with results

 

 

 

8d64cd54ccae2d9e88186e01e8d19635.png

  • 0
Posted
5 minutes ago, jcsnider said:

Mind opening a bug report regarding 

http://*:5400/ not working via the config along with the error above?

 

Sure, will do right away.

 

Trying to make a cmd file on autostart the server with --apiport=5400

Do you know if this is the correct?

 

filename: startServer.cmd

 

content of file:

cd C:\Users\Lenovo\Desktop\Server
start Intersect_Server.exe --apiport=5400

  • 0
Posted
9 minutes ago, jcsnider said:

I think it would just be:

 

"Intersect Server.exe" --apiport=5400

 

Not completely sure for windows though.

Didn't work for Windows 10, still same error when http://localhost:5400

Will try to find the correct alternative for --apiport=5400 for windows

  • 0
Posted

On windows if you get this error

2019-09-13 16:47:51.244 [Error] Failed to start API.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.HttpListenerException: Access is denied

It likely means you need to run as admin. Windows has urlacl which controls the hostnames/ports you can listen on.

 

Alternatively you can use the urlacl command to give your account access to that hostname (http://*:5400) info linked below: (running as admin is easier imo)

https://docs.microsoft.com/en-us/windows/win32/http/add-urlacl

  • 0
Posted
56 minutes ago, jcsnider said:

On windows if you get this error


2019-09-13 16:47:51.244 [Error] Failed to start API.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.HttpListenerException: Access is denied

It likely means you need to run as admin. Windows has urlacl which controls the hostnames/ports you can listen on.

 

Alternatively you can use the urlacl command to give your account access to that hostname (http://*:5400) info linked below: (running as admin is easier imo)

https://docs.microsoft.com/en-us/windows/win32/http/add-urlacl

 

 

I made a file.cmd with the following content:

cd C:\Users\Lenovo\Desktop\Server
"Intersect_Server.exe" --apiport=5400

 

Then I made a shortcut to that file to always run as admin. Will test to access the API from another computer now and also external.

  • 0
Posted

I created a new task to run my shortcut as admin when the user has logged in, now the server starts at computer boot up.

 

@jcsnider

Seems like --apiport=5400 did the trick.

 

Can confirm that it is now working both from another computer internal on the same network and an external network.

 

7d9b4973b5e8bd73eec314ae455aeeed.png

 

×
×
  • Create New...