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

Hostport on config file still does not work #27

Closed
wutkemtt opened this issue Jun 26, 2019 · 11 comments
Closed

Hostport on config file still does not work #27

wutkemtt opened this issue Jun 26, 2019 · 11 comments

Comments

@wutkemtt
Copy link

The host and port setting in config file is still ignored. The standard host and port will be used.
When using the commandline parameter -hp everything works as expected.

@sasbury
Copy link
Contributor

sasbury commented Jun 26, 2019

Can you send me a sample of your config file and command line (they can be fake, just want to see what flags and contents you are using.) I wrote a test and didn't see this problem. I will check in the test regardless, but want to make sure it replicates what you are doing.

@wutkemtt
Copy link
Author

Thanks for the fast response. We used the config below, trying to use the account server as a master for another account server. In the first step we tried to reach the account server from a nats on another server.

OperatorJWTPath: "X:/some_path/NATS.jwt" systemaccountjwtpath: "X:/some_path/SYS.jwt" http: { host: "HOSTA", port: 9090, readtimeout: 5000, writetimeout: 5000 } store: { dir: "D:/nats/as_store", readonly: false, shard: false } logging: { debug: true, pid: true, time: true, trace: false, colors: true } nats: { servers: ["nats://HOSTA:4243","nats://HOSTB:4243"], usercredentials: "X:/some_path/admin.creds", ConnectTimeout: 5000, #MaxReconnects: 50 ReconnectWait: 10000 }

We were not able to access the account server on HOSTA from HOSTB. After setting the command line option "-hp" with the same value the account server was reachable.
nats-account-server.exe -c nats-account-server.config -ro -hp "HOSTA:9090"

Just before we realised, that when we set the host and port in the config and the server comes up, the log still shows the deafult resolver url:
[20144] 2019/06/19 09:25:48.398664 [←[32mINF←[0m] resolver: URL(http://localhost:9090/jwt/v1/accounts/)

After switching to commandline the log showed:
[19648] 2019/06/19 10:21:33.063197 [←[32mINF←[0m] resolver: URL(http://HOSTA:9090/jwt/v1/accounts/)

Hope, this will help to find the cause of the problem.

@sasbury
Copy link
Contributor

sasbury commented Jun 27, 2019

hm, that is almost exactly my test, can you check that you have the latest version from master, we may not have updated the releases or something.

@sasbury
Copy link
Contributor

sasbury commented Jun 28, 2019

wutkemtt let me know if you get a chance to try the latest code in master, i am curious if my test is somehow doing something different than your run.

@wutkemtt
Copy link
Author

wutkemtt commented Jul 1, 2019

Hello,
I tried the latest code this morning with the same result. The http settings in the config file are completely ignored. Neither a different host nor a different port is used when set via config file. When adding the same values on the command line via the -hp option the setting is working.
Could it be that the complete http section is ignored within the config file ?
Other sections like store, logging and nats are working.

@sasbury
Copy link
Contributor

sasbury commented Jul 1, 2019 via email

@sasbury
Copy link
Contributor

sasbury commented Jul 3, 2019

Hm, i updated my test with your config file and I still see the host coming through:

func TestStartWithConfigFileFlag(t *testing.T) {
	file, err := ioutil.TempFile(os.TempDir(), "config")
	require.NoError(t, err)

	configString := `
	OperatorJWTPath: "X:/some_path/NATS.jwt"
	systemaccountjwtpath: "X:/some_path/SYS.jwt"
	http: {
		host: "HOSTA",
		port: 9090,
		readtimeout: 5000,
		writetimeout: 5000 }
	store: {
		dir: "D:/nats/as_store",
		readonly: false,
		shard: false }
	logging: { 
		debug: true,
		pid: true,
		time: true,
		trace: false,
		colors: true }
	nats: { 
		servers: ["nats://HOSTA:4243","nats://HOSTB:4243"], 
		usercredentials: "X:/some_path/admin.creds", 
		ConnectTimeout: 5000,
		ReconnectWait: 10000
	}
	`

	fullPath, err := conf.ValidateFilePath(file.Name())
	require.NoError(t, err)

	err = ioutil.WriteFile(fullPath, []byte(configString), 0644)
	require.NoError(t, err)

	flags := Flags{
		ConfigFile: fullPath,
	}

	server := NewAccountServer()
	err = server.InitializeFromFlags(flags)
	require.NoError(t, err)

	require.Equal(t, "D:/nats/as_store", server.config.Store.Dir)
	require.Equal(t, 5000, server.config.HTTP.ReadTimeout)
	require.Equal(t, "HOSTA", server.config.HTTP.Host)
	require.Equal(t, 9090, server.config.HTTP.Port)
}

Does anything jump out to you, maybe i have a typo I am missing?

@sasbury
Copy link
Contributor

sasbury commented Jul 8, 2019

bah, i see the issue, the flags are defaulting to localhost:9090 and that has precedent. Testing a fix.

@sasbury
Copy link
Contributor

sasbury commented Jul 8, 2019

Should be fixed, confirmed with test and manually.

@sasbury sasbury closed this as completed Jul 8, 2019
@sasbury
Copy link
Contributor

sasbury commented Jul 8, 2019

If you can't confirm fix, please feel free to reopen.

@wutkemtt
Copy link
Author

I can confirm the fix is working. Host and port are taken from config now and the server is reachable as expected. Thanks.

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