Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Erroneous string format using mosquitto_sub/_pub #15123

Copy link
Copy link
@chris-steema

Description

@chris-steema
Issue body actions

Steps to reproduce

Run the following *.ps1 script in a text file with UTF-8 ecoding:

while ($true)
{ 
  $date = Get-Date -Format "o"
  $rand = Get-Random -Minimum -10 -Maximum 40
  $message = '{"time":' + '"' + "$date" + '"' + ', "value":' + "$rand" + ', "label":"ºC"}'
  #echo "$message"
  mosquitto_pub -h test.mosquitto.org -t tofol/test -m "$message"
  Start-Sleep -s 1
}

Now in another terminal window, subscribe to the mosquitto topic:

mosquitto_sub -h test.mosquitto.org -t tofol/test

The output is unexpected:

{time:2021-03-30T12:30:24.0266957+02:00, value:3, label:║C}

Expected behavior

Expected behavior is seem by running the following script:

while ($true)
{ 
  $date = Get-Date -Format "o"
  $rand = Get-Random -Minimum -10 -Maximum 40
  $message = '{"time":' + '"' + "$date" + '"' + ', "value":' + "$rand" + ', "label":"ºC"}'
  echo "$message"
  #mosquitto_pub -h test.mosquitto.org -t tofol/test -m "$message"
  Start-Sleep -s 1
}

This outputs:
{"time":"2021-03-30T12:31:48.2728626+02:00", "value":33, "label":"ºC"}

Environment data

Name                           Value
----                           -----
PSVersion                      7.1.3
PSEdition                      Core
GitCommitId                    7.1.3
OS                             Microsoft Windows 10.0.19041
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.