Ionic + Cpacitor Electron, NAME_NOT_RESOLVED for socket.io requests

Open
#4,512 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
electron, nodejs, typescript

Research direction

Start by reproducing the issue with node server.js, the Ionic web app, and the Electron tasks, then inspect /src/pages/Home.tsx and the /electron directory. Done means the Electron version reaches the server without the ERR_NAME_NOT_RESOLVED request failure described in the issue.

Written by the indexing model from the issue text.

Description

needs investigation

Describe the bug

Situation:
I made a repository for testing: https://github.com/ZweiEuro/electron_socket_test

It has:
server.js - minimal socket io server that just console.logs conections. CORS * so that is not an issue. Listening 3002

A minimal ionic blank project with socket-client installed. The web version just prompts for an ip address and tries to connect to it.
Mainly defined in /src/pages/Home.tsx. Always connecting to :3002

A lot of tasks defined for easier debugging.

The ionic project has https://github.com/capacitor-community/electron installed as a platform, it's data is located in /electron. It should behave the same way as the ionic web page

The Problem:

Using the app Web version:

  1. Running node server.js
  2. Running ionic serve
  3. Navigating browser to http://localhost:8100/home
  4. Entering your machines ip address in the prompt will connect to it
  5. Console says "connect" both for the server and the web client => works as intended

Using the app electron version:
(Since electron does not support 'prompt' in their window, you need to hard code the address of the server into Home.tsx, if you do this you need to rebuild (run the tasks again)

  1. Using the tasks "run electron" or "pack electron" (and starting it manually)
  2. open electron dev tools
  3. See error
GET http://capacitor-electron/socket.io/?EIO=4&transport=polling&t=OGz8z5U net::ERR_NAME_NOT_RESOLVED

To me it looks like something is getting rewritten incorrectly?

To Reproduce

  1. clone https://github.com/ZweiEuro/electron_socket_test
  2. npm i in both electron and the root directory
  3. Run the commands listed above, it is easier to start vscode in the directory and using the tasks
  4. Web version works, electron version throws the above error
Dominant language
TypeScript
Stars
63.2k
Forks
10.3k
Avg merge
11d 20h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from socketio/socket.io

All issues in socketio/socket.io

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.