Closed ShuzhaoFeng closed 5 months ago
There's a lot going on here, are you able to reproduce the problem with a plain JavaScript or TypeScript program?
There's a lot going on here, are you able to reproduce the problem with a plain JavaScript or TypeScript program?
While trying to reproduce, I realized that the issue comes from erroneously using AMQPClient
instead of AMQPWebSocketClient
for a non-node project. Additional modules (node-libs-react-native
, react-native-tcp
, stream
, stream-browserify
, text-encoding
) are still needed to support amqp-client
in an Expo React Native project.
I'll turn my example code shortly to a minimally reproducible example for using the module in an Expo React Native environment.
Minimal example now available: https://github.com/ShuzhaoFeng/amqp-client-expo-example
Problem Description
Cannot instantiate an
AMQPClient
instance becausename
isundefined
.System Specs
OS:
Windows 11 Pro 23H2
node version:v20.11.1
npm version:10.5.2
npx version:10.5.2
npx expo version:0.17.10
Expo package version:50.0.14
React package version:18.2.0
React Native package version:0.73.6
CloudAMQP Specs
Type: LavinMQ Active Plan: Loyal Lemming Region: amazon-web-services::ca-central-1 Cluster: rabbit.lmq.cloudamqp.com (DNS load balanced) Hosts: rabbit-01.lmq.cloudamqp.com(Availability Zone cac1-az4)
Example Code
https://github.com/ShuzhaoFeng/cloud-amqp-expo-test
Note that CloudAMQP credentials has been explicitly omitted before the push.
Steps to Reproduce (With Example Code)
Clone the repository
cd my-app
npm run start
Open the app on Expo and notice the error
Steps to Reproduce (Without Example Code)
npx create-expo-app --template
Select blank TypeScript template
cd my-app
npm i @cloudamqp/amqp-client
In
App.tsx
, add the following import:App.tsx
, add the following lines at the beginning of theApp()
function:npm run start
Open the app on expo, and notice the following error:
Ctrl+C to stop the app
npm i node-libs-react-native react-native-tcp stream-browserify stream
npx expo customize metro.config.js
In the newly Created metro.config.js file, add the following just above the line
module.exports = config
:npm run start
Open the app again and notice the error
Error Log