Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebsocketProvider on React-Native url == null #2602

Closed
jacksonng77 opened this issue Mar 28, 2019 · 9 comments
Closed

WebsocketProvider on React-Native url == null #2602

jacksonng77 opened this issue Mar 28, 2019 · 9 comments
Labels
Bug Addressing a bug

Comments

@jacksonng77
Copy link

I am on 1.0.0-beta.50 and React-Native 0.57 via expo SDK 32.0

I am trying to connect to a private ethereum node with the following codes:

const web3 = new Web3(
	new Web3.providers.WebsocketProvider('wss://u0yyyar44q-u0nczix681-wss.us-east-2.kaleido.io', {headers:{authorization: 'Basic dTBxdGxkcTVkdzpMWFh5WUtLVzIyZEFJUDhTNm9sWEFSbzNkZDFEYkYwS1VYc3laUm5saXVv'}})
);

web3.eth.getBlock("latest").then((latestBlock) => {
console.log("Latest Block Via HTTP Provider: ")
console.log(latestBlock);

I am unable to connect to my node. The following error is shown.

url == null

@nivida
Copy link
Contributor

nivida commented Mar 28, 2019

Thanks for opening this issue! There is already a PR regarding this issue (#2593). I will check it closer and release the fix asap.

@nivida nivida added the Bug Addressing a bug label Mar 28, 2019
@jacksonng77
Copy link
Author

Thank you nivida!

I wish to add that the same codes work in node.js but on React-Native, it gives me

url == null

@sirpy
Copy link

sirpy commented Jan 7, 2020

this is caused by a bug in websocket module of react native
this PR fixes it
facebook/react-native#27702
you can patch your react-native in the meantime

@ravi0the0sun
Copy link

ravi0the0sun commented Dec 20, 2020

well i have this problem using websocket provider instead of http provider

const provider = new Web3(
	new Web3.providers.WebsocketProvider(
		`wss://${NETWORK}.infura.io/v3/${INFURA_API_KEY}`
	)
);
[Sun Dec 20 2020 19:51:49.756]  ERROR    Error: not implemented
[Sun Dec 20 2020 19:51:49.758]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
[Sun Dec 20 2020 19:51:50.812]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)

Environment info:

System:
    OS: macOS 10.15.7
    CPU: (4) x64 Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
    Memory: 568.42 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 14.15.1 - /var/folders/nf/83z965450dd46qzdlrd86t6h0000gn/T/fnm_multishell_4962_1608455072599/bin/node
    Yarn: 1.22.10 - /var/folders/nf/83z965450dd46qzdlrd86t6h0000gn/T/fnm_multishell_4962_1608455072599/bin/yarn
    npm: 6.14.9 - /var/folders/nf/83z965450dd46qzdlrd86t6h0000gn/T/fnm_multishell_4962_1608455072599/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.0 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.2, DriverKit 19.0, macOS 10.15, tvOS 14.2, watchOS 7.1
    Android SDK:
      API Levels: 28, 29, 30
      Build Tools: 28.0.3, 29.0.2, 30.0.2
      System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom_64, android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom_64, android-29 | Google Play Intel x86 Atom_64, android-30 | Google APIs Intel x86 Atom, android-30 | Google APIs Intel x86 Atom_64, android-30 | Google Play Intel x86 Atom, android-30 | Google Play Intel x86 Atom_64
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.6953283
    Xcode: 12.1.1/12A7605b - /usr/bin/xcodebuild
  Languages:
    Java: javac 15 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.3 => 0.63.3 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

@sirpy
Copy link

sirpy commented Dec 20, 2020

@ravi0the0sun did you use the patch?
#2602 (comment)

@ravi0the0sun
Copy link

do you known how to do that @sirpy as the PR hasnt been pushed yet.

@sirpy
Copy link

sirpy commented Dec 21, 2020 via email

@ravi0the0sun
Copy link

ravi0the0sun commented Dec 22, 2020

hi @sirpy i applied the patch to my node_moduels but the error still there and im not sure where this error is being thrown from.
simulator_screenshot_141C3E7D-8103-4AFD-9554-0E5212898525

@sirpy
Copy link

sirpy commented Dec 22, 2020

it seems like RN implementation of URL is very minimal
see here
chrisbobbe/zulip-mobile@c675cdd

facebook-github-bot pushed a commit to facebook/react-native that referenced this issue Jan 19, 2021
Summary:
Conform with Websocket javascript api.
related to web3js issues: web3/web3.js#2864 web3/web3.js#2602

Reviewed By: javache

Differential Revision: D25927475

Pulled By: TheSavior

fbshipit-source-id: 26b2df0565dac581d546b6824dd4f0fc2c8cdc32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Addressing a bug
Projects
None yet
Development

No branches or pull requests

4 participants