8000 socket connection is not terminated on closing window, when client.create() is called from browser process. · Issue #40 · Quramy/electron-connect · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

socket connection is not terminated on closing window, when client.create() is called from browser process. #40

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

Closed
ssreekanth opened this issue May 19, 2016 · 0 comments · Fixed by #44

Comments

@ssreekanth
Copy link
Collaborator
ssreekanth commented May 19, 2016

Single Window Scenario : This is mostly applicable to OS X, where app.quit() is not called on window-all-closed event (as a result of second bullet point in Step 1 below). On other platforms, app.quit() gets called, which would force close the socket connection.

Multiple Window Scenario : The issue can be seen, when any of the multiple windows is closed.

Steps to recreate the issue

  1. As shown in the code below, make sure the following are done.
  • call client.create() in the browser process (app.js)
  • on app window-all-closed event, make sure app.quit() is not called on OS X.
  • on window close event, set window handle to null.

app.js

'use strict';

var electron = require('electron');
var app = electron.app;
var BrowserWindow = electron.BrowserWindow;
var client = require('../../').client;

app.on('window-all-closed', function () {
  if (process.platform != 'darwin') {
    app.quit();
  }
});

app.on('ready', function () {
  console.log(process.argv.join(', '));
  console.log('Hello, browser process');
  var mainWindow = new BrowserWindow({
    width: 400,
    height: 300
  });

  mainWindow.loadURL('file://' + __dirname + '/index.html');

  mainWindow.on('closed', function() {
    mainWindow = null;
  });

  client.create(mainWindow);
});

index.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Simple example app</title>
</head>
<body>
<h1>Hello, Electron</h1>
<script src="index.js"></script>
</body>
</html>
  1. Run gulp serve command.
  2. Close the window.

Expected Behavior

this.close() gets called and socket is terminated.

Actual Behavior

beforeunload event handler is not getting invoked. Hence, socket doesn't get terminated.

ssreekanth added a commit to ssreekanth/electron-connect that referenced this issue Jun 5, 2016
ssreekanth added a commit to ssreekanth/electron-connect that referenced this issue Jun 5, 2016
@ssreekanth ssreekanth changed the title 'beforeunload' event handler in client.js not getting invoked, when client.create() is called from browser process. socket connection is not getting closed, when client.create() is called from browser process. Jun 5, 2016
@ssreekanth ssreekanth mentioned this issue Jun 5, 2016
@ssreekanth ssreekanth changed the title socket connection is not getting closed, when client.create() is called from browser process. socket connection is not terminated on closing window, when client.create() is called from browser process. Jun 7, 2016
ssreekanth added a commit to ssreekanth/electron-connect that referenced this issue Jun 10, 2016
Quramy added a commit that referenced this issue Aug 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant
0