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

Crash at startup with token.p8 - bad_auth #206

Closed
theanhoo opened this issue Oct 2, 2022 · 3 comments · Fixed by #216
Closed

Crash at startup with token.p8 - bad_auth #206

theanhoo opened this issue Oct 2, 2022 · 3 comments · Fixed by #216

Comments

@theanhoo
Copy link

theanhoo commented Oct 2, 2022

I am trying to start MongoosePush ver 2.1.0 from the command line:
_build/prod/rel/mongoose_push/bin/mongoose_push start

It would crash with the following errors:

{
   "application":"mongoose_push",
   "at":"Elixir.MongoosePush.Service.APNS.Supervisor.convert_token_pool_to_sparrow/2:150",
   "erl_level":"error",
   "file":"lib/mongoose_push/service/apns/supervisor.ex",
   "key":null,
   "mode":"dev",
   "p8_file":"/home/developer/MongoosePush-master/_build/prod/rel/mongoose_push/lib/mongoose_push-2.1.0/priv/apns/token.p8",
   "pid":"#PID<0.1801.0>",
   "reason":"bad_auth",
   "result":"error",
   "severity":"error",
   "team":null,
   "text":"Required configuration missing",
   "what":"configuration",
   "when":"2022-10-02T19:02:12.722",
   "domain[0]":"elixir"
}
{
  "application": "mongoose_push",
  "at": "Elixir.MongoosePush.Service.APNS.Supervisor.convert_token_pool_to_sparrow/2:150",
  "erl_level": "error",
  "file": "lib/mongoose_push/service/apns/supervisor.ex",
  "key": null,
  "mode": "prod",
  "p8_file": "/home/developer/MongoosePush-master/_build/prod/rel/mongoose_push/lib/mongoose_push-2.1.0/priv/apns/token.p8",
  "pid": "#PID<0.1801.0>",
  "reason": "bad_auth",
  "result": "error",
  "severity": "error",
  "team": null,
  "text": "Required configuration missing",
  "what": "configuration",
  "when": "2022-10-02T19:02:12.722",
  "domain[0]": "elixir"
}

I have copied the files from Apple into the /home/developer/MongoosePush-master/_build/prod/rel/mongoose_push/lib/mongoose_push-2.1.0/priv directories.

Does anyone have any idea or solution about these?

It says "Required configuration missing" but it doesn't seem to be using any files under the config directory.

Many thanks in advance.

@szjozsef
Copy link

szjozsef commented Oct 19, 2022

Same here, with the mention that the first error logged is:

{
	"application": "mongoose_push",
	"at": "Elixir.MongoosePush.Application.check_runtime_configuration_status/0:212",
	"erl_level": "info",
	"file": "lib/mongoose_push/application.ex",
	"pid": "#PID<0.1802.0>",
	"reason": "no_release",
	"severity": "info",
	"status": "error",
	"text": "Skipping TOML configuration due to non-release boot",
	"what": "toml_configuration",
	"when": "2022-10-19T06:38:14.772",
	"domain[0]": "elixir"
}

This with the "latest" docker release
Maybe it is related to the #204
The config.toml is there, is valid, at least it is working well with the previous docker image: mongooseim/mongoose-push:235ab4d
The config.toml is parsed (if some I set some invalid values, then at the start the correct error is logged), but somehow get overwritten ? and the application starts with some kind of default configuration, at least that can be the reason why tries to parse p8_file, even if I had not configured such kind of options in apns section.
My config.toml is pretty much similar to the example from: guides/configuration.md

Maybe the issue is that in mix.exs the Config lines order was reversed in the last commits:

        config_providers: [
          {MongoosePush.Config.Provider.Toml, [path: "var/config.toml"]},
          {MongoosePush.Config.Provider.Confex, []}
        ]

and it seems the Toml generated config get's overwritten by the default config via Confex

@pawlooss1
Copy link
Member

@theanhoo it seems like MongoosePush is really using the default config which for MIX_ENV=prod fails if some required values are not configured. In this case you have "key":null, "team":null which should be set when using token auth. Also, the "p8_file" is also default: priv/apns/token.p8. Could you show me your configuration file? Or maybe you're setting your base config via environmental variables?

@pawlooss1
Copy link
Member

pawlooss1 commented Mar 6, 2024

@szjozsef Thanks for pointing out to that PR. However, it is not the order of config providers that causes the issue. Confex will override only those options which were not set previously and can be defined in environmental variables. It is this change which causes such log. Old code would set such flag to later indicate in the logs if TOML config was used. However, this log should be harmless because other configuration options should be set MongoosePush.Config.Provider.Toml. The real problem is that the system is trying to configure pools from both TOML configuration and environment variables configuration which fails if the required ones are not defined. I'll prepare a fix for this.

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

Successfully merging a pull request may close this issue.

3 participants