-
Notifications
You must be signed in to change notification settings - Fork 25
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
MqttConnectionSettings.CreateFromEnvVars does not work if the env var value contains '=' #95
Comments
what's the reason of passing the api-version in the username? |
Some services require this api-version structure in the MQTT connect username, so clients need to be able to provide this. |
Using the USERNAME field to specify api-version seems questionable. Can we discuss with service owners? btw, I guess you could specify the value with quotes:
|
But the client doesn't control what the server requires in the connect username field. The "api-version=" is one case I ran across but I suppose a username could have an '=' in it, like a username "foo=bar". The current implementation does not support surrounding the value with quotes. If supporting quoted values is the preferred solution to this problem, then let's specify that (and ensure that the implementation supports escaping quotes as well for values that contain quotes). BTW, is there a spec for .env files that describes what they should and should not support? I couldn't find one with a quick search. |
Yeah, I'd say that allowing quotes is the preferred solution. AFAIK there is no "formal" spec, see this doc from docker https://docs.docker.com/compose/environment-variables/env-file/ |
Okay, so in order to address this issue, the designers of the MQTTnet client extensions library will need to define what features are supported in a .env file:
|
well, there is no such extension library, just a project used in these samples :) We started with .env files to avoid loading connection strings in C (that requires more parsing), other languages/tools have .env files already implemented, so we added basic .NET support based on https://dusted.codes/dotenv-in-dotnet. But it was not a core requirement for .NET. For .NET I'd recommend using connection strings instead of .env files. |
Okay, but is there a standard definition for an MQTT connection string? I couldn't find this, either. For readability, which is probably one of the points of these samples, the .env key=value approach is nice. Either way, the connection settings input format should be specified and then implemented. Since this issue is narrowly about the .env file and the '=' character, would you prefer that I open an issue that is used for specifying the connection settings for these samples? |
I'm not aware neither, we are defining our own here Is that document enough? if not, feel free to file a new issue |
This issue is for a: (mark with an
x
)Minimal steps to reproduce
Call MqttConnectionSettings.CreateFromEnvVars with a file containing a variable that contains an '=' in the value, such as MQTT_USERNAME=reg-cp-1/registrations/device-1/api-version=2023-12-01-preview
Any log messages given by the failure
Silent failure.
Expected/desired behavior
Environment variables with '=' in value are used.
Language
C#
OS and Version?
Any
The text was updated successfully, but these errors were encountered: