Amplify mock subscription error: "Connection failed: An invalid or illegal string was specified"
See original GitHub issueDescribe 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
- Create react app
- run amplify init
- add graphql api with api key (for test i’ve tried with api key and cognito user pool)
- npm install amplify modules
- deploy to server
- copy paste code below
- run aginst server and see connection
- 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:
- Created 4 years ago
- Reactions:1
- Comments:8 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
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.