Skip to content

"AMQJS0005E Internal error. Error Message: AMQJS0009E Malformed UTF data" when receiving base64 data #14228

@sshakyaUR

Description

@sshakyaUR

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

PubSub

Amplify Version

v6

Amplify Categories

Not applicable

Backend

Other

Environment information

Details
  System:
    OS: Windows 11 10.0.22631
    CPU: (12) x64 13th Gen Intel(R) Core(TM) i5-1345U
    Memory: 14.17 GB / 31.69 GB
  Binaries:
    Node: 20.18.3 - ~\AppData\Local\fnm_multishells\2412_1740070471687\node.EXE
    npm: 10.8.2 - ~\AppData\Local\fnm_multishells\2412_1740070471687\npm.CMD
  Browsers:
    Chrome: 133.0.6943.99
    Edge: Chromium (132.0.2957.140)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    @aws-amplify/pubsub: ^6.1.44 => 6.1.44 
    @eslint/js: ^9.13.0 => 9.20.0 
    @types/react: ^18.3.12 => 18.3.18
    @types/react-dom: ^18.3.1 => 18.3.5
    @vitejs/plugin-react: ^4.3.3 => 4.3.4
    aws-amplify: ^6.13.0 => 6.13.0
    aws-amplify/adapter-core:  undefined ()
    aws-amplify/adapter-core/internals:  undefined ()
    aws-amplify/analytics:  undefined ()
    aws-amplify/analytics/kinesis:  undefined ()
    aws-amplify/analytics/kinesis-firehose:  undefined ()
    aws-amplify/analytics/personalize:  undefined ()
    aws-amplify/analytics/pinpoint:  undefined ()
    aws-amplify/api:  undefined ()
    aws-amplify/api/internals:  undefined ()
    aws-amplify/api/server:  undefined ()
    aws-amplify/auth:  undefined ()
    aws-amplify/auth/cognito:  undefined ()
    aws-amplify/auth/cognito/server:  undefined ()
    aws-amplify/auth/enable-oauth-listener:  undefined ()
    aws-amplify/auth/server:  undefined ()
    aws-amplify/data:  undefined ()
    aws-amplify/data/server:  undefined ()
    aws-amplify/datastore:  undefined ()
    aws-amplify/in-app-messaging:  undefined ()
    aws-amplify/in-app-messaging/pinpoint:  undefined ()
    aws-amplify/push-notifications:  undefined ()
    aws-amplify/push-notifications/pinpoint:  undefined ()
    aws-amplify/storage:  undefined ()
    aws-amplify/storage/s3:  undefined ()
    aws-amplify/storage/s3/server:  undefined ()
    aws-amplify/storage/server:  undefined ()
    aws-amplify/utils:  undefined ()
    eslint: ^9.13.0 => 9.20.1
    eslint-plugin-react-hooks: ^5.0.0 => 5.1.0
    eslint-plugin-react-refresh: ^0.4.14 => 0.4.19
    globals: ^15.11.0 => 15.15.0 (11.12.0, 14.0.0)
    react: ^18.3.1 => 18.3.1
    react-dom: ^18.3.1 => 18.3.1
    typescript: ~5.6.2 => 5.6.3
    typescript-eslint: ^8.11.0 => 8.24.1
    vite: ^5.4.10 => 5.4.14
  npmGlobalPackages:
    corepack: 0.30.0
    npm: 10.8.2

Describe the bug

I am subscribed to a topic that publishes base64 data, that I then plan on decocing once I receive the data. When I receive the data, I get this warning message in Amplify's ConsoleLogger, and the next() function after subscribing does not run.

[WARN] 47:51.6 MqttOverWS - AppContext-22 {
  "errorCode": 5,
  "errorMessage": "AMQJS0005E Internal error. Error Message: AMQJS0009E Malformed UTF data:8b -78 ., Stack trace: No Error Stack Available",
  "uri": ...
  | _log | @ | ConsoleLogger.ts:94
  | warn | @ | ConsoleLogger.ts:130
  | onDisconnect | @ | MqttOverWS.ts:100
  | client.onConnectionLost | @ | MqttOverWS.ts:121
  | ClientImpl._disconnected | @ | paho-mqtt.js:1838
  | ClientImpl._handleMessage | @ | paho-mqtt.js:1671
  | ClientImpl._on_socket_message | @ | paho-mqtt.js:1407
  | (anonymous) | @ | paho-mqtt.js:196

It seems like it's failing at the try/catch block in the _handleMessage function of paho-mqtt.js

Testing with regular JSON works fine. How can I get Pubsub to work with zipped data?

Expected behavior

I am able to unzip the received packet.

Reproduction steps

  1. Subscribe to a topic.
  2. Publish to the topic a gzipped packet

Code Snippet

  useEffect(() => {
    if (isAuthenticated) {
      (async () => {
        pubsub
          .subscribe({
            topics: [`dev/${identityId}/users/${identityId}`],
          })
          .subscribe({
            next: () => {
              console.log("here");
            },
          });
      })();
    }
  }, [isAuthenticated, identityId]);

Log output

Details
[DEBUG] 23:49.503 CognitoCredentialsProvider - returning stored credentials as they neither past TTL nor expired. | ConsoleLogger.ts:94 
[DEBUG] 23:49.504 MqttOverWS - Creating new MQTT client AppContext-10
[WARN] 47:51.6 MqttOverWS - AppContext-22 {
  "errorCode": 5,
  "errorMessage": "AMQJS0005E Internal error. Error Message: AMQJS0009E Malformed UTF data:8b -78 ., Stack trace: No Error Stack Available",
  "uri": ...
  | _log | @ | ConsoleLogger.ts:94
  | warn | @ | ConsoleLogger.ts:130
  | onDisconnect | @ | MqttOverWS.ts:100
  | client.onConnectionLost | @ | MqttOverWS.ts:121
  | ClientImpl._disconnected | @ | paho-mqtt.js:1838
  | ClientImpl._handleMessage | @ | paho-mqtt.js:1671
  | ClientImpl._on_socket_message | @ | paho-mqtt.js:1407
  | (anonymous) | @ | paho-mqtt.js:196

aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    PubSubRelated to PubSub categoryfeature-requestRequest a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions