question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Amplify mock subscription error: "Connection failed: An invalid or illegal string was specified"

See original GitHub issue

Describe the bug The same code that works when subscribing to an AppSync endpoint doesn’t work when using amplify mock.

Amplify CLI Version 4.13.1

To Reproduce

  1. Create react app
  2. run amplify init
  3. add graphql api with api key (for test i’ve tried with api key and cognito user pool)
  4. npm install amplify modules
  5. deploy to server
  6. copy paste code below
  7. run aginst server and see connection
  8. run amplify mock and see error

Code:

import React, { useEffect } from 'react';
import Amplify from '@aws-amplify/core';
import API from '@aws-amplify/api';
import PubSub from '@aws-amplify/pubsub';
import config from './aws-exports';
import { onCreateMyType } from './graphql/subscriptions';

Amplify.configure(config);
PubSub.configure(config);

// Amplify.Logger.LOG_LEVEL = 'DEBUG';

function App() {
  useEffect(() => {
    let subscription;

    const run = () => {
      subscription = API.graphql({
        query: onCreateMyType,
      }).subscribe({
        next: response => console.log('response', response),
        error: response => console.log('error response', response),
      });
    };

    run();

    return () => subscription.unsubscribe();
  }, []);

  return <div>Pub Sub Test</div>;
}

export default App;

Expected behavior Be able to test subscriptions locally

Desktop (please complete the following information):

  • OS: macOS
  • Node Version: v12.10.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
yuthcommented, Mar 16, 2020

The only way to use it would be to use older version of Amplify JS libraries (@aws-amplify/pubsub@1.x.x), which may have bug that got fixed along the way

0reactions
github-actions[bot]commented, May 26, 2021

This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AmplifyJS error when Appsync subscribe is exposed via API ...
It worked well for Query & Mutate Request. But for Subscribe request, I am getting a handshake exception. (Connection failed: Connection ...
Read more >
Advanced Voir Dire & Jury Selection (Part 1) - GoJoLaw
Skill in jury selection is the most amorphous and difficult to teach of all of the basic trial skills. There are certain fundamental...
Read more >
AB3121 Reparations Task Force Meeting Materials Part 1
Mr. Ramsey voiced his opinion regarding the. War on Drugs, finding it have been a failure. He believed it failed on many levels...
Read more >
Country Reports on Terrorism 2017 - State Department
Coordination was uneven, with improved information sharing in some cases and failure to appropriately pass threat information in others.
Read more >
Class Index - Android Developers
AccessControlProfile, A class used to specify access controls. ... Thrown to indicate that an array has been accessed with an illegal index.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found