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

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

Open
3 tasks done
sshakyaUR opened this issue Feb 20, 2025 · 1 comment
Labels
feature-request Request a new feature PubSub Related to PubSub category

Comments

@sshakyaUR
Copy link

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

PubSub

Amplify Version

v6

Amplify Categories

Not applicable

Backend

Other

Environment information

  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

[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

@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending a response from the Amplify team. labels Feb 20, 2025
@HuiSF HuiSF added PubSub Related to PubSub category investigating This issue is being investigated labels Feb 20, 2025
@jjarvisp
Copy link
Member

Hi @sshakyaUR, thanks for reporting this issue. It's possible this might be a limitation of the paho-mqtt dependency. We will investigate this and come up with some next steps.

@jjarvisp jjarvisp removed investigating This issue is being investigated pending-triage Issue is pending triage labels Feb 20, 2025
@github-actions github-actions bot removed the pending-maintainer-response Issue is pending a response from the Amplify team. label Feb 20, 2025
@jjarvisp jjarvisp added bug Something isn't working feature-request Request a new feature and removed bug Something isn't working labels Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request a new feature PubSub Related to PubSub category
Projects
None yet
Development

No branches or pull requests

3 participants