I also have it, :S .env STREAMS_WEBHOOK_URL = '/streams-webhook'
init route local and stream url:
app.use(
streamsSync(parseServer, {
apiKey: config.MORALIS_API_KEY,
webhookUrl: config.STREAMS_WEBHOOK_URL
}),
app for create stream:
app.post("/AuctionCreated", async (req: any, res: any) => {
try {
console.log("STREAMS_WEBHOOK_URL", `${url}${config.STREAMS_WEBHOOK_URL}`);
const webHookUrl = `${url}${config.STREAMS_WEBHOOK_URL}`;
const chaindIdFinal = chainID.testNet;
const stream = await Moralis.Streams.add({
chains: [EvmChain.MUMBAI],
description: 'AuctionsCreated721',
tag: 'AuctionsCreated',
abi: marketAbi,
includeContractLogs: true,
topic0: [
'AuctionCreated(address,uint256,uint8,uint256,uint256,uint256,address)'
],
webhookUrl: webHookUrl,
});
const { id } = stream.toJSON();
await Moralis.Streams.addAddress({
address,
id
});
} catch(e) {
console.log("Not Moralis", e);
}
return res. send('ok');
})
initserver:
const httpServer = http.createServer(app);
httpServer.listen(config.PORT, async() => {
if (config.USE_STREAMS) {
url = await ngrok.connect(config.PORT);
// eslint-disable-next-line no-console
console.log(
`Moralis Server is running on port ${config.PORT} and stream webhook url ${url}${config.STREAMS_WEBHOOK_URL}`,
);
} else {
// eslint-disable-next-line no-console
console.log(`Moralis Server is running on port ${config.PORT}.`);
}
});
everything is fine, I donât understand why it doesnât work, I had ruled out ngrok because of the answers they gave me, that the error is my code, but the stream does not connect in any way, before changing the api, if I created the streams in the normal way , no longer, checking I realized that ngrok was not being created for me either, I went to the node_modules folder, look for ngrok/bin and configure the api there, with the command ngrok config add-authtoken xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
and if the ngrok url worked again, it returned the moralis server, that is, the ngrok error no longer gives me, but now I have one more question, a second question, the route to create the stream ( /streams-webhook
) does not work for me, and to configure the ngrok api How would it be done on a deployed server?
note: I think that between tests and local tests, I exhausted the number of ngrok, which I had by default.