Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

489
Views
Error: Socket cerrado con evento 1002 en cliente apollo

estoy tratando de hacer una suscripción del cliente apollo al servidor, en el servidor uso apollo-server-express.

La suscripción funciona bien en el área de juegos de graphql, pero cuando intento conectar mi cliente al servidor, aparece este error.

Aquí está la parte del código donde uso useSubscription

  1. Mensaje.js (cliente)
 const MESSAGE_CREATED_SUBSCRIPTION=gql` subscription{ messageCreated{ content from to } } ` const {data:messageData,error:messageError}=useSubscription(MESSAGE_CREATED_SUBSCRIPTION) useEffect(()=>{ console.log(messageError) },[messageData,messageError])

2.index.js (cliente)

 const authLink = setContext((req) => { let token = localStorage.getItem("token"); return { headers: { Authorization: token ? `Bearer ${token}` : "", }, }; }); let httpLink = createHttpLink({ uri: "http://localhost:4000/graphql", }); const wsLink = new GraphQLWsLink( createClient({ url: "ws://localhost:4000/graphql", reconnect:true, connectionParams: { authToken: `Bearer ${localStorage.getItem("token")}`, }, }) ); httpLink=authLink.concat(httpLink) const splitLink = split( ({ query }) => { const definition = getMainDefinition(query); return ( definition.kind === "OperationDefinition" && definition.operation === "subscription" ); }, wsLink, httpLink ); const client = new ApolloClient({ link: splitLink, cache: new InMemoryCache(), });

El mensaje de error que he estado recibiendo

 Error: Socket closed with event 1002 at Object.error (index.ts:68:1) at client.mjs:411:1

3.La pestaña de red ingresa la descripción de la imagen aquí

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!