xmtp / xmtp-js

XMTP client SDKs, content types, and other packages written in TypeScript
https://xmtp.org/docs
211 stars 40 forks source link

validating token: token expired' #254

Closed paschal533 closed 1 year ago

paschal533 commented 1 year ago

Hi, I am getting this error validating token: token expired' while trying to use @xmtp/xmtp-js on my Nextjs app

Jonathansoufer commented 1 year ago

Hey @paschal533 did you followed the QuickStart and/or the Example NextJS app? Could you share the snippet, log or process where you facing such issue?

paschal533 commented 1 year ago

Hi @Jonathansoufer, I followed the quickstart. Here is the code below.

import { useEffect, useContext } from "react";
import { Client } from '@xmtp/xmtp-js'
import { ethers } from 'ethers'
import Web3Modal from "web3modal";

useEffect(() => {
    const getMes = async () => {
       try {
        const web3Modal = new Web3Modal();
        const connection = await web3Modal.connect();
        const provider = new ethers.providers.Web3Provider(connection);
        const signer = provider.getSigner();
        const xmtp = await Client.create(signer)

        const conversation = await xmtp.conversations.newConversation(
          '0x00024FA2CBaF665aFaF272712261d600ef8AC1c4'
        )

        const messages = await conversation.messages()
        await conversation.send('gm')

        for await (const message of await conversation.streamMessages()) {
          console.log(`[${message.senderAddress}]: ${message.content}`)
        }
       }catch(error) {
        console.log(error)
       }
    }

     getMes();
  }, []);

When I run the code, it will pop up my metamask and ask me to sign two transactions... after that, it will console out this error.

{code: 16, message: 'validating token: token expired', details: Array(0)}
Jonathansoufer commented 1 year ago

Hey @paschal533 , thank you for sharing your code. I tried it on a fresh Next.JS project (see below) and worked perfectly connecting to Goerli network. So, from the snippet itself, seems to be all good. Are you working in an OS that you could share and allow us to debug together?

Screenshot 2023-01-12 at 2 03 41 PM

nplasterer commented 1 year ago

Closing this out because of inactivity. Please feel free to reopen if you are still having issues.