Open tylermakin opened 5 years ago
Thanks again for opening the issue here!
I opened another issue because this error is not handled properly by the Amplify API and a fallback cannot be built until this error is recognized and handled: Bug: GraphQL subscriptions do not throw error on websocket failure
Give it a try with our new WebSockets implementation, it should return an error: https://aws.amazon.com/blogs/mobile/appsync-realtime/
Give it a try with our new WebSockets implementation, it should return an error: https://aws.amazon.com/blogs/mobile/appsync-realtime/
Hi @awsed , this might be a separate issue.
But for this new pure WebSocket thing, what if we use a custom domain name for appsync address?
There is no appsync-api
in our custom domain name, therefore no appsync-realtime-api
either.
If you want to use the new pure WebSockets support your client must connect to the appsync-realtime-api endpoint. If you're using the AppSync SDK or Amplify clients they will automatically detect the endpoints. If you are not using the default endpoints on your client then you'll have to do it in your code manually as AppSync does not have built-in support for custom domains yet.
Thanks @awsed , I guess we need two domains. One as appsync-api.domain.com
another as appsync-realtime-api.domain.com
. Just for matching the AppSync SDK .
@bpceee we faced the same problem. As a workaround, we configured the Apollo client manually using AppSync's subscription link using "MQTT over Websockets" https://github.com/awslabs/aws-mobile-appsync-sdk-js/blob/master/packages/aws-appsync-subscription-link/src/subscription-handshake-link.ts.
import { createAuthLink } from 'aws-appsync-auth-link';
import { createSubscriptionHandshakeLink } from 'aws-appsync-subscription-link';
import { ApolloLink } from 'apollo-link';
import { createHttpLink } from 'apollo-link-http';
import ApolloClient from 'apollo-client';
import { InMemoryCache } from 'apollo-cache-inmemory';
import appSyncConfig from "./aws-exports";
const url = appSyncConfig.aws_appsync_graphqlEndpoint;
const region = appSyncConfig.aws_appsync_region;
const auth = {
type: appSyncConfig.aws_appsync_authenticationType,
apiKey: appSyncConfig.aws_appsync_apiKey,
};
const httpLink = createHttpLink({ uri: url });
const link = ApolloLink.from([
createAuthLink({ url, region, auth }),
createSubscriptionHandshakeLink(url, httpLink)
]);
const client = new ApolloClient({
link,
cache: new InMemoryCache()
})
The feature request here is to offer a long polling endpoint that uses HTTP sans WebSockets? Please :+1: if this would be helpful for you!
Bump, any update?
In building a recent B2B webapp, we discovered that some corporate networks block websockets. Similarly, some proxies cause websockets to appear open but do not allow any data through. Appsync cannot be used in these situations because its subscriptions rely on websockets without a fallback.
Appsync needs to support an alternative to websockets for passing real-time data through subscriptions where websockets cannot be used.
See this Stack Overflow question for details.