beholder |
|
Статус: Новичок Группы: Участники
|
Окружение:
Что делаю:
Не понимаю в чем проблема, помогите плиз. Сделал лог установки на всякий случай, хотя установка прошла успешно. Здесь Отредактировано пользователем 16 июля 2015 г. 14:49:39(UTC) |
|
|
beholder |
|
Статус: Новичок Группы: Участники
|
Здравствуйте. Есть ли у кого-нибудь какие-нибудь мысли по этому поводу? |
|
|
cross |
|
Статус: Сотрудник Группы: Администраторы, Участники Сказал(а) «Спасибо»: 3 раз |
http://www.cryptopro.ru/…des/demopage/simple.html |
Техническую поддержку оказываем тут. |
|
|
|
beholder |
|
Статус: Новичок Группы: Участники
|
Да, спасибо. Понял свою ошибку. Код:
который никак не обрабатывает сообщение с типом type: «init» Отредактировано пользователем 22 июля 2015 г. 14:54:40(UTC) |
|
|
beholder |
|
Статус: Новичок Группы: Участники
|
Покопался еще. Код:
Google подсказывает, что для работы через native messaging host необходимо этот хост зарегистрировать в системе используя специальный manifest file |
|
|
beholder |
|
Статус: Новичок Группы: Участники
|
Похоже у вас сломался инсталятор. Поставил версию плагина 2.0.2051, и тестовая страничка заработала. |
|
|
paradoxm |
|
Статус: Активный участник Группы: Участники Сказал «Спасибо»: 1 раз |
Недавно обновили расширение для хрома на 1.0.7, а так же поменяли код работы с плагином. Вроде все поправил у себя На нашем сайте отображает и версию плагина и что он установлен Но получаю ошибку в консоль браузера Uncaught TypeError: g_resolve_function[event.data.data.requestid] is not a function Подскажите куда копать? Где чего не дописал? Сейчас попробовал вставить полностью ваш код с демо страницы и все равно такая ошибка валится. Отредактировано пользователем 21 августа 2015 г. 23:52:51(UTC) |
|
|
cross |
|
Статус: Сотрудник Группы: Администраторы, Участники Сказал(а) «Спасибо»: 3 раз |
Таких сообщений не видел, можете сделать тестовую страницу что бы это воспроизвести? На нашей тестовой странице тоже такие ошибки идут? |
Техническую поддержку оказываем тут. |
|
|
|
paradoxm |
|
Статус: Активный участник Группы: Участники Сказал «Спасибо»: 1 раз |
На вашей странице таких сообщений нет. Не могу найти причину (((. Сделать тестовую страницу? Что вы имеете ввиду? |
|
|
cross |
|
Статус: Сотрудник Группы: Администраторы, Участники Сказал(а) «Спасибо»: 3 раз |
Сделать страницу test.html что бы можно было ее открыть в chrome и посмотреть на эту ошибку. |
Техническую поддержку оказываем тут. |
|
|
|
Пользователи, просматривающие эту тему |
Guest |
Быстрый переход
Вы не можете создавать новые темы в этом форуме.
Вы не можете отвечать в этом форуме.
Вы не можете удалять Ваши сообщения в этом форуме.
Вы не можете редактировать Ваши сообщения в этом форуме.
Вы не можете создавать опросы в этом форуме.
Вы не можете голосовать в этом форуме.
I’m getting an «Inside onDisconnected(): Error when communicating with the native messaging host.» when sending a message from my native host app to the browser extension.
There are several things that can cause this:
1) Incorrect length sent at beginning of message, or improper order of length bytes sent (endianness).
2) Not putting stdout in binary mode before writing to it (if stdout is in text mode extra bytes can be added apart from your code).
3) Not sending the message as valid json in UTF-8. Actually I’m not certain that invalid json would be rejected, but the docs say the message should be json.
The code is:
int nStdOutDescriptor = _fileno(stdout);
int result = _setmode( nStdOutDescriptor, _O_BINARY );
if( result == -1 )
{
OutputDebugStringA ("Failed attempting to set stdout to binary modern");
return;
}
HANDLE hStdOut = (HANDLE) _get_osfhandle(nStdOutDescriptor);
if (INVALID_HANDLE_VALUE != hStdOut)
{
char *results = "{"results":"0000"}";
std::string sMsg(results);
int nMsgLen = sMsg.length();
unsigned char first = (unsigned char)(nMsgLen & 0x000000ff);
unsigned char second = (unsigned char)((nMsgLen >> 8) & 0x000000ff);
unsigned char third = (unsigned char)((nMsgLen >> 16) & 0x000000ff);
unsigned char fourth = (unsigned char)((nMsgLen >> 24) & 0x000000ff);
char *bufMsg = new char[4 + nMsgLen]; // allocate message buffer
const char *pMessageBytes = sMsg.c_str();
memcpy( &bufMsg[4], &pMessageBytes[0], nMsgLen);
bufMsg[0] = first;
bufMsg[1] = second;
bufMsg[2] = third;
bufMsg[3] = fourth;
DWORD dwNumBytesToWrite = nMsgLen + 4;
DWORD dwNumBytesWritten;
if (TRUE == WriteFile(hStdOut, (LPVOID)pMessageBytes, dwNumBytesToWrite, &dwNumBytesWritten, NULL))
{
BTrace (L"WriteFile() succeeded. Returned TRUE. %lu bytes written", dwNumBytesWritten );
}
_close(nStdOutDescriptor);
}
All three of the likely causes do not seem to be occurring. But I cannot discover any detailed info (even from looking at the source that Google provides) about what is causing my particular error message. WriteFile() succeeds and the number of bytes written is 22 bytes. There are 22 total bytes written, 4 of which are the length bytes. I’ve verified that the first 4 bytes are (in decimal, not hex): 18,0,0,0 which in little-endian fashion indicates how many bytes follow to make up the json message. When I use DebugView to peek at my json message it is always: {«results»:»0000″}. That’s 18 bytes/chars. I’ve even experimented with sending escaped double-quotes in case that is preferred. In the browser extension’s background page my onDisconnected() event is called which reports the last chrome runtime error message (that’s where I’m getting the error msg defining this question). This means the connection between the extension and the native host app is being shut down. Help would be greatly appreciated.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ’s.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki — it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
-
richardcc
- Posts: 9
- Joined: Thu May 29, 2014 11:06 pm
Chrome: Error when communicating with the native messaging
Hello Good Day,
Hi support team, I have a big problem to communicate my CSV file because when I run a simple macro I receive the problem say, Error: Error when communicating with the native messaging host…
I am using
Chrome browser Version 35.0.1916.114 beta-m
iMacros for Chrome 8.0.5
VERSION BUILD=6060703 RECORDER=CR
OS Windows 7 Ultimate 32 bit/ service Pack 1
I refer Installation Guide here http://wiki.imacros.net/iMacros_for_Chrome#Installation
Last few days ago, my macros work very will and after Imacros launching auto upgrade recently, I am now face a problem like this.. Error: Error when communicating with the native messaging host., line: 6
I am using simple auto login on Facebook and my script below.
Code: Select all
VERSION BUILD=6060703 RECORDER=CR
SET !REPLAYSPEED FAST
SET !TIMEOUT_PAGE 50
SET !TIMEOUT_STEP 50
SET !DATASOURCE /Users/richardcc/Documents/iMacros/Datasources/newaccount.csv
SET !DATASOURCE_COLUMNS 4
SET !DATASOURCE_LINE {{!LOOP}}
SET !LOOP 1
URL GOTO=https://www.facebook.com/tv
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:login_form ATTR=ID:email CONTENT={{!COL1}}
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=ID:login_form ATTR=ID:pass CONTENT=ASDDFFDS
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:login_form ATTR=ID:u_0_0
Sorry I am not good in English, I am only learn basic info from this forum and not an expert.
I appreciate to your support.
…
Thanks
Richard
-
chivracq
- Posts: 10239
- Joined: Sat Apr 13, 2013 1:07 pm
- Location: Amsterdam (NL)
Re: Chrome: Error when communicating with the native messagi
Post
by chivracq » Fri Aug 08, 2014 10:53 am
sivaprakash.2k8 wrote:Same issue i have faced. Can you please clarify the issue.
CIM…!
Could you please clarify your Issue…?
— (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + ‘Free’/’PE’/’Trial’).
— I don’t even read the Qt if that (required) Info is not mentioned…!
— Script & URL help a lot for more «educated» Help…
-
sivaprakash.2k8
- Posts: 4
- Joined: Fri Aug 08, 2014 8:46 am
Re: Chrome: Error when communicating with the native messagi
Post
by sivaprakash.2k8 » Tue Aug 12, 2014 9:36 am
Hi
VERSION BUILD=8070701 RECORDER=CR
URL GOTO=somewebsite
SET !TIMEOUT 300
SET !DATASOURCE Books1.csv
SET !DATASOURCE_COLUMNS 14
SET !DATASOURCE_LINE {{!LOOP}}
WAIT SECONDS=5
TAG POS=1 TYPE=A ATTR=TXT:Submit
FRAME F=9
TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F2912 CONTENT=${{!COL1}}
TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1359 CONTENT=${{!COL2}}
TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1347 CONTENT=${{!COL3}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:SubmitForm ATTR=ID:F1337 CONTENT={{!COL4}}
WAIT SECONDS=2
TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1350 CONTENT=${{!COL5}}
WAIT SECONDS=2
TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1351 CONTENT=${{!COL6}}
WAIT SECONDS=2
TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1515 CONTENT=${{!COL7}}
WAIT SECONDS=2
TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1712 CONTENT=${{!COL8}}
WAIT SECONDS=2
TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1354 CONTENT=${{!COL9}}
WAIT SECONDS=2
TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1425 CONTENT=${{!COL10}}
WAIT SECONDS=2
TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1426 CONTENT=${{!COL11}}
WAIT SECONDS=2
TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1718_LEFT CONTENT=${{!COL12}}
TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1372 CONTENT=${{!COL13}}
TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F4422 CONTENT=${{!COL14}}
FRAME F=8
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:formbtns ATTR=ID:formbtns_ok
When i tried to run this in LOOP, am getting the error «Error: Error when communicating with the native messaging host., line: 5»..
Kinly do the need ful
-
chivracq
- Posts: 10239
- Joined: Sat Apr 13, 2013 1:07 pm
- Location: Amsterdam (NL)
Re: Chrome: Error when communicating with the native messagi
Post
by chivracq » Tue Aug 12, 2014 10:04 am
sivaprakash.2k8 wrote:Hi
Code: Select all
VERSION BUILD=8070701 RECORDER=CR URL GOTO=somewebsite SET !TIMEOUT 300 SET !DATASOURCE Books1.csv SET !DATASOURCE_COLUMNS 14 SET !DATASOURCE_LINE {{!LOOP}} WAIT SECONDS=5 TAG POS=1 TYPE=A ATTR=TXT:Submit FRAME F=9 TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F2912 CONTENT=${{!COL1}} TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1359 CONTENT=${{!COL2}} TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1347 CONTENT=${{!COL3}} TAG POS=1 TYPE=INPUT:TEXT FORM=ID:SubmitForm ATTR=ID:F1337 CONTENT={{!COL4}} WAIT SECONDS=2 TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1350 CONTENT=${{!COL5}} WAIT SECONDS=2 TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1351 CONTENT=${{!COL6}} WAIT SECONDS=2 TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1515 CONTENT=${{!COL7}} WAIT SECONDS=2 TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1712 CONTENT=${{!COL8}} WAIT SECONDS=2 TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1354 CONTENT=${{!COL9}} WAIT SECONDS=2 TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1425 CONTENT=${{!COL10}} WAIT SECONDS=2 TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1426 CONTENT=${{!COL11}} WAIT SECONDS=2 TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1718_LEFT CONTENT=${{!COL12}} TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F1372 CONTENT=${{!COL13}} TAG POS=1 TYPE=SELECT FORM=ID:SubmitForm ATTR=ID:F4422 CONTENT=${{!COL14}} FRAME F=8 TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:formbtns ATTR=ID:formbtns_ok
When i tried to run this in LOOP, am getting the error «Error: Error when communicating with the native messaging host., line: 5»..
Kinly do the need ful
That’s already better, but CR Version is still missing and OS is missing as well. («FCIM» means FULL Config Info Missing… Can’t you read the Forum Rules about what Info is needed when reporting a Problem…?) It is important because big Changes were introduced in CR35 and again to come in CR36 and your OS dictates which FIO Component to install…
Is your Macro a File or a Bookmark Macro…?
Do you have the Problem as well with the ‘Loop-Web-2-Csv.iim’ Demo Macro…? (Also mentioned in the Forum Rules…)
— (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + ‘Free’/’PE’/’Trial’).
— I don’t even read the Qt if that (required) Info is not mentioned…!
— Script & URL help a lot for more «educated» Help…
-
sivaprakash.2k8
- Posts: 4
- Joined: Fri Aug 08, 2014 8:46 am
Re: Chrome: Error when communicating with the native messagi
Post
by sivaprakash.2k8 » Thu Aug 14, 2014 9:51 am
Operating System: Windows 7
System Type: 64Bit
Browser:
Google Chrome: Version 36.0.1985.125 m
Installed IMACROS as Extension in Browser.
I dont know how to Identify the CR.
IMACROS Version : 8.0.7
Am just a Beginner so I was not able to provide the information you are required for.
Just tell me how and where can i find the details.
Thanks,
Sivaprakash M
-
sivaprakash.2k8
- Posts: 4
- Joined: Fri Aug 08, 2014 8:46 am
Re: Chrome: Error when communicating with the native messagi
Post
by sivaprakash.2k8 » Thu Aug 14, 2014 9:54 am
My Macros is saved as FILE.
C:UserssivaDocumentsiMacrosMacrossample.iim
Yes, I have a problem with the Demo Macro ‘Loop-Web-2-Csv.iim’ too. Getting this error «RuntimeError: Data source file does not exist, line: 6»
-
jagdishgg
- Posts: 1
- Joined: Mon Aug 18, 2014 4:27 pm
- Contact:
Re: Chrome: Error when communicating with the native messagi
Post
by jagdishgg » Mon Aug 18, 2014 4:36 pm
Exactly same error
Error: Error when communicating with the native messaging host
Config:
explorer: Chrome
OS : Windows 7
VERSION BUILD=8070701 RECORDER=CR
VERSION BUILD=8070701 RECORDER=CR
TAB T=1
TAB CLOSEALLOTHERS
SET !ERRORIGNORE YES
SET !DATASOURCE F:TechspertsinstagramAddress1.csv
SET !LOOP 1
WAIT SECONDS=25
SET !DATASOURCE_LINE {{!LOOP}}
URL GOTO=http://www.theuaeexpats.com/
TAG POS=1 TYPE=TEXTAREA FORM=ACTION:/post_comment ATTR=ID:textarea_784127891409_1455920 CONTENT={{!COL1}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:/post_comment ATTR=NAME:submit
I have changed the url here as I cant provide original url
I am reading values from csv.It worked till 16th Aug but not working since 17th Aug.
Jagsy
www.theuaeexpats.com
-
chivracq
- Posts: 10239
- Joined: Sat Apr 13, 2013 1:07 pm
- Location: Amsterdam (NL)
Re: Chrome: Error when communicating with the native messagi
Post
by chivracq » Mon Aug 18, 2014 7:18 pm
jagdishgg wrote:Exactly same error
Error: Error when communicating with the native messaging host
Config:Code: Select all
explorer: Chrome OS : Windows 7 VERSION BUILD=8070701 RECORDER=CR
Code: Select all
VERSION BUILD=8070701 RECORDER=CR TAB T=1 TAB CLOSEALLOTHERS SET !ERRORIGNORE YES SET !DATASOURCE F:TechspertsinstagramAddress1.csv SET !LOOP 1 WAIT SECONDS=25 SET !DATASOURCE_LINE {{!LOOP}} URL GOTO=http://www.theuaeexpats.com/ TAG POS=1 TYPE=TEXTAREA FORM=ACTION:/post_comment ATTR=ID:textarea_784127891409_1455920 CONTENT={{!COL1}} TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:/post_comment ATTR=NAME:submit
I have changed the url here as I cant provide original url
I am reading values from csv.It worked till 16th Aug but not working since 17th Aug.
You don’t mention your CR Version… CR35 broke iMacros a few weeks ago due to a Change in CR35 and new Changes were supposed to come again in CR36. Maybe CR recently updated itself…?
Do you have the Problem with the Demo as well…?
Last edited by chivracq on Wed Nov 23, 2016 2:53 pm, edited 1 time in total.
— (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + ‘Free’/’PE’/’Trial’).
— I don’t even read the Qt if that (required) Info is not mentioned…!
— Script & URL help a lot for more «educated» Help…
-
jizzle
- Posts: 1
- Joined: Wed Nov 23, 2016 11:55 am
Re: Chrome: Error when communicating with the native messagi
Post
by jizzle » Wed Nov 23, 2016 11:57 am
Hi, I recently ran into the exact same error.
CR Version is 54
thanks in advance
-
chivracq
- Posts: 10239
- Joined: Sat Apr 13, 2013 1:07 pm
- Location: Amsterdam (NL)
Re: Chrome: Error when communicating with the native messagi
Post
by chivracq » Wed Nov 23, 2016 3:02 pm
jizzle wrote:Hi, I recently ran into the exact same error.
thanks in advance
FCIM…! (Read my Sig…)
Yeah, but, pfff…, your Post is very vague…!
You need to mention your complete FCI, the original Thread was already from 2.5 years ago with «Standard» FCI at that time v8.0.7 + CR35, «we» are now at CR54, 20 Versions later…!! And «Standard» iMacros for CR Version is now v8.4.4.
And how do you get this Error?, what is your Script doing?, provide some mini-Macro reproducing the Pb or using some Demo-Macro…
— (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + ‘Free’/’PE’/’Trial’).
— I don’t even read the Qt if that (required) Info is not mentioned…!
— Script & URL help a lot for more «educated» Help…
-
imacrosid
- Posts: 18
- Joined: Sun Feb 07, 2016 10:36 am
Re: Chrome: Error when communicating with the native messagi
Post
by imacrosid » Thu Nov 09, 2017 5:52 pm
chivracq wrote:
jizzle wrote:Hi, I recently ran into the exact same error.
thanks in advance
FCIM…!
(Read my Sig…)
Yeah, but, pfff…, your Post is very vague…!
![]()
You need to mention your complete FCI, the original Thread was already from 2.5 years ago with «Standard» FCI at that time v8.0.7 + CR35, «we» are now at CR54, 20 Versions later…!! And «Standard» iMacros for CR Version is now v8.4.4.And how do you get this Error?, what is your Script doing?, provide some mini-Macro reproducing the Pb or using some Demo-Macro…
next problem from my thread this http://forum.imacros.net/viewtopic.php? … 188#p76188
when i do loop 10 it’s just do 9 , when i do 25 it’s just do 24, last play loop get error like this thread
Code: Select all
Error: Native host has exited., line: 30
help me again chivracq
-
chivracq
- Posts: 10239
- Joined: Sat Apr 13, 2013 1:07 pm
- Location: Amsterdam (NL)
Re: Chrome: Error when communicating with the native messagi
Post
by chivracq » Thu Nov 09, 2017 6:14 pm
imacrosid wrote:
chivracq wrote:
jizzle wrote:Hi, I recently ran into the exact same error.
thanks in advance
FCIM…!
(Read my Sig…)
Yeah, but, pfff…, your Post is very vague…!
![]()
You need to mention your complete FCI, the original Thread was already from 2.5 years ago with «Standard» FCI at that time v8.0.7 + CR35, «we» are now at CR54, 20 Versions later…!! And «Standard» iMacros for CR Version is now v8.4.4.And how do you get this Error?, what is your Script doing?, provide some mini-Macro reproducing the Pb or using some Demo-Macro…
next problem from my thread this http://forum.imacros.net/viewtopic.php? … 188#p76188
when i do loop 10 it’s just do 9 , when i do 25 it’s just do 24, last play loop get error like this threadCode: Select all
Error: Native host has exited., line: 30
help me again chivracq
Yeah, but sorry @imacrosid, the «Quality» of your Post is too poor, I’ll pass on this one…
I’ve already told you that I that don’t do any «Digging» in a Thread if FCI is not mentioned in your OP when you open a Thread or post for the first time in some existing Thread like for this current Thread… And the original Thread is from more than 3 years ago, several Versions were released since…
— (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + ‘Free’/’PE’/’Trial’).
— I don’t even read the Qt if that (required) Info is not mentioned…!
— Script & URL help a lot for more «educated» Help…
I am trying to use Chrome extension native messaging feature. I had the C# program running, which will use standard output to write data. And in the chrome extension background.js file, chrome.runtime.onConnectExternal.addListener() was never fired.
In the chrome extension page, I had following error:
Unchecked runtime.lastError: Error when communicating with the native messaging host.
Context_generated_background_page.html
Stack Trace
_generated_background_page.html:0 (anonymous function)
Following are the info about the testing project.
-
C# application. This method will be called once even triggered in the application.
public static void Write(JToken data) { var json = new JObject(); json["data"] = data; var bytes = System.Text.Encoding.UTF8.GetBytes(json.ToString(Formatting.None)); /* foreach (var b in bytes) Console.WriteLine(b); */ var stdout = Console.OpenStandardOutput(); stdout.WriteByte((byte)((bytes.Length >> 0) & 0xFF)); stdout.WriteByte((byte)((bytes.Length >> 8) & 0xFF)); stdout.WriteByte((byte)((bytes.Length >> 16) & 0xFF)); stdout.WriteByte((byte)((bytes.Length >> 24) & 0xFF)); stdout.Write(bytes, 0, bytes.Length); stdout.Flush(); }
-
background.js (update 1)
var port = chrome.runtime.connectNative('applistener'); port.onMessage.addListener(function(msg) { console.log("Received" + msg); }); port.onDisconnect.addListener(function() { console.log("Disconnected"); });
-
Chrome extension manifest file(manifest.json).
"permissions": [ "nativeMessaging","activeTab", "declarativeContent", "storage"],
-
Native application manifest file.(almanifest.json)
{ "name": "applistener", "description": "Chrome native messaging test", "path": "C:\Users\xyz\_test\AppListener\AppListener\bin\Release\AppListener.exe", "type": "stdio", "allowed_origins": [ "chrome-extension://xxxxxmanextensionidxxxxxx/"]
}
-
Create registry key.
Followed the instruction from :https://developer.chrome.com/extensions/nativeMessaging#native-messaging-host-location
And I can see the key from ComputerHKEY_CURRENT_USERSoftwareGoogleChromeNativeMessagingHostsapplistener
I am assuming when the event fired in the native app, in the chrome extension background.js, the listener event should be triggered. But I did not see that event triggered.
Update1:
Change the code in background.js, using code sample from google documentation. port.onDisconnect.addListener() event fired, still get the error:
Unchecked runtime.lastError: Error when communicating with the native messaging host.
I am trying to narrow down the issue at this point. I guess my registry key setting is correct? and write method in native app is the issue?
I am trying to use Chrome extension native messaging feature. I had the C# program running, which will use standard output to write data. And in the chrome extension background.js file, chrome.runtime.onConnectExternal.addListener() was never fired.
In the chrome extension page, I had following error:
Unchecked runtime.lastError: Error when communicating with the native messaging host.
Context_generated_background_page.html
Stack Trace
_generated_background_page.html:0 (anonymous function)
Following are the info about the testing project.
-
C# application. This method will be called once even triggered in the application.
public static void Write(JToken data) { var json = new JObject(); json["data"] = data; var bytes = System.Text.Encoding.UTF8.GetBytes(json.ToString(Formatting.None)); /* foreach (var b in bytes) Console.WriteLine(b); */ var stdout = Console.OpenStandardOutput(); stdout.WriteByte((byte)((bytes.Length >> 0) & 0xFF)); stdout.WriteByte((byte)((bytes.Length >> 8) & 0xFF)); stdout.WriteByte((byte)((bytes.Length >> 16) & 0xFF)); stdout.WriteByte((byte)((bytes.Length >> 24) & 0xFF)); stdout.Write(bytes, 0, bytes.Length); stdout.Flush(); }
-
background.js (update 1)
var port = chrome.runtime.connectNative('applistener'); port.onMessage.addListener(function(msg) { console.log("Received" + msg); }); port.onDisconnect.addListener(function() { console.log("Disconnected"); });
-
Chrome extension manifest file(manifest.json).
"permissions": [ "nativeMessaging","activeTab", "declarativeContent", "storage"],
-
Native application manifest file.(almanifest.json)
{ "name": "applistener", "description": "Chrome native messaging test", "path": "C:\Users\xyz\_test\AppListener\AppListener\bin\Release\AppListener.exe", "type": "stdio", "allowed_origins": [ "chrome-extension://xxxxxmanextensionidxxxxxx/"]
}
-
Create registry key.
Followed the instruction from :https://developer.chrome.com/extensions/nativeMessaging#native-messaging-host-location
And I can see the key from ComputerHKEY_CURRENT_USERSoftwareGoogleChromeNativeMessagingHostsapplistener
I am assuming when the event fired in the native app, in the chrome extension background.js, the listener event should be triggered. But I did not see that event triggered.
Update1:
Change the code in background.js, using code sample from google documentation. port.onDisconnect.addListener() event fired, still get the error:
Unchecked runtime.lastError: Error when communicating with the native messaging host.
I am trying to narrow down the issue at this point. I guess my registry key setting is correct? and write method in native app is the issue?
Important: Chrome will be removing support for Chrome Apps on all platforms. Chrome browser and the Chrome Web Store will continue to support extensions. Read the announcement and learn more about migrating your app.
Extensions and apps can exchange messages with native applications using an API that is similar to the other message passing APIs. Native applications that support this feature must register a native messaging host that knows how to communicate with the extension. Chrome starts the host in a separate process and communicates with it using standard input and standard output streams.
Native messaging host
In order to register a native messaging host the application must install a manifest file that defines the native messaging host configuration. Below is an example of the manifest file:
{
"name": "com.my_company.my_application",
"description": "My Application",
"path": "C:\Program Files\My Application\chrome_native_messaging_host.exe",
"type": "stdio",
"allowed_origins": [
"chrome-extension://knldjmfmopnpolahpmmgbagdohdnhkik/"
]
}
The native messaging host manifest file must be valid JSON and contains the following fields:
Name | Description |
---|---|
name |
Name of the native messaging host. Clients pass this string to runtime.connectNative or runtime.sendNativeMessage. This name can only contain lowercase alphanumeric characters, underscores and dots. The name cannot start or end with a dot, and a dot cannot be followed by another dot. |
description |
Short application description. |
path |
Path to the native messaging host binary. On Linux and OSX the path must be absolute. On Windows it can be relative to the directory in which the manifest file is located. The host process is started with the current directory set to the directory that contains the host binary. For example if this parameter is set to C:Applicationnm_host.exe then it will be started with current directory C:Application . |
type |
Type of the interface used to communicate with the native messaging host. Currently there is only one possible value for this parameter: stdio . It indicates that Chrome should use stdin and stdout to communicate with the host. |
allowed_origins |
List of extensions that should have access to the native messaging host. Wildcards such as chrome-extension://*/* are not allowed. |
Native messaging host location
The location of the manifest file depends on the platform.
On Windows, the manifest file can be located anywhere in the file system. The application installer must create registry key HKEY_LOCAL_MACHINESOFTWAREGoogleChromeNativeMessagingHosts_com.my_company.my_application_
or HKEY_CURRENT_USERSOFTWAREGoogleChromeNativeMessagingHosts_com.my_company.my_application_
, and set default value of that key to the full path to the manifest file. For example, using the following command:
REG ADD "HKCUSoftwareGoogleChromeNativeMessagingHostscom.my_company.my_application" /ve /t REG_SZ /d "C:pathtonmh-manifest.json" /f
or using the following .reg
file:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USERSoftwareGoogleChromeNativeMessagingHostscom.my_company.my_application]
@="C:\path\to\nmh-manifest.json"
When Chrome looks for native messaging hosts, first the 32-bit registry is queried, then the 64-bit registry.
On OS X and Linux, the location of the native messaging host’s manifest file varies by the browser (Google Chrome or Chromium). The system-wide native messaging hosts are looked up at a fixed location, while the user-level native messaging hosts are looked up in a subdirectory within the user profile directory called NativeMessagingHosts
.
- OS X (system-wide)
- Google Chrome:
/Library/Google/Chrome/NativeMessagingHosts/_com.my_company.my_application_.json
- Chromium:
/Library/Application Support/Chromium/NativeMessagingHosts/_com.my_company.my_application_.json
- Google Chrome:
- OS X (user-specific, default path)
- Google Chrome:
~/Library/Application Support/Google/Chrome/NativeMessagingHosts/_com.my_company.my_application_.json
- Chromium:
~/Library/Application Support/Chromium/NativeMessagingHosts/_com.my_company.my_application_.json
- Google Chrome:
- Linux (system-wide)
- Google Chrome:
/etc/opt/chrome/native-messaging-hosts/_com.my_company.my_application_.json
- Chromium:
/etc/chromium/native-messaging-hosts/_com.my_company.my_application_.json
- Google Chrome:
- Linux (user-specific, default path)
- Google Chrome:
~/.config/google-chrome/NativeMessagingHosts/_com.my_company.my_application_.json
- Chromium:
~/.config/chromium/NativeMessagingHosts/_com.my_company.my_application_.json
- Google Chrome:
Native messaging protocol
Chrome starts each native messaging host in a separate process and communicates with it using standard input (stdin
) and standard output (stdout
). The same format is used to send messages in both directions: each message is serialized using JSON, UTF-8 encoded and is preceded with 32-bit message length in native byte order. The maximum size of a single message from the native messaging host is 1 MB, mainly to protect Chrome from misbehaving native applications. The maximum size of the message sent to the native messaging host is 4 GB.
The first argument to the native messaging host is the origin of the caller, usually chrome-extension://[ID of allowed extension]
. This allows native messaging hosts to identify the source of the message when multiple extensions are specified in the allowed_origins
key in the native messaging host manifest. Warning: In Windows, in Chrome 54 and earlier, the origin was passed as the second parameter instead of the first parameter.
When a messaging port is created using runtime.connectNative Chrome starts native messaging host process and keeps it running until the port is destroyed. On the other hand, when a message is sent using runtime.sendNativeMessage, without creating a messaging port, Chrome starts a new native messaging host process for each message. In that case the first message generated by the host process is handled as a response to the original request, i.e. Chrome will pass it to the response callback specified when runtime.sendNativeMessage is called. All other messages generated by the native messaging host in that case are ignored.
On Windows, the native messaging host is also passed a command line argument with a handle to the calling Chrome native window: --parent-window=<decimal handle value>
. This lets the native messaging host create native UI windows that are correctly parented. Note that this value will be 0 if the calling context is a background script page.
Connecting to a native application
Sending and receiving messages to and from a native application is very similar to cross-extension messaging. The main difference is that runtime.connectNative is used instead of runtime.connect, and runtime.sendNativeMessage is used instead of runtime.sendMessage. These methods can only be used if the «nativeMessaging» permission is declared in your app’s manifest file.
The Following example creates a runtime.Port object that’s connected to native messaging host com.my_company.my_application
, starts listening for messages from that port and sends one outgoing message:
var port = chrome.runtime.connectNative('com.my_company.my_application');
port.onMessage.addListener(function(msg) {
console.log("Received" + msg);
});
port.onDisconnect.addListener(function() {
console.log("Disconnected");
});
port.postMessage({ text: "Hello, my_application" });
runtime.sendNativeMessage can be used to send a message to native application without creating a port, e.g.:
chrome.runtime.sendNativeMessage('com.my_company.my_application',
{ text: "Hello" },
function(response) {
console.log("Received " + response);
});
Debugging native messaging
When the native messaging host fails to start, writes to stderr
or when it violates the communication protocol, output is written to the error log of Chrome. On Linux and OS X, this log can easily be accessed by starting Chrome from the command line and watching its output in the terminal. On Windows, use --enable-logging
as explained at How to enable logging.
Here are some errors and tips for solving the issues:
- Failed to start native messaging host.
- Check whether you have sufficient permissions to execute the file.
- Invalid native messaging host name specified.
- Check whether the name contains any invalid characters. Only lowercase alphanumeric characters, underscores and dots are allowed. A name cannot start or end with a dot, and a dot cannot be followed by another dot.
- Native host has exited.
- The pipe to the native messaging host was broken before the message was read by Chrome. This is most likely initiated from your native messaging host.
- Specified native messaging host not found.
- Is the name spelled correctly in the extension and in the manifest file?
- Is the manifest put in the right directory and with the correct name? See native messaging host location for the expected formats.
- Is the manifest file in the correct format? In particular, is the JSON syntax correct and do the values match the definition of a native messaging host manifest?
- Does the file specified in
path
exist? On Windows, paths may be relative, but on OS X and Linux, the paths must be absolute.
- Native messaging host host name is not registered. (Windows-only)
- The native messaging host was not found in the Windows registry. Double-check using
regedit
whether the key was really created and matches the required format as documented at native messaging host location.
- The native messaging host was not found in the Windows registry. Double-check using
- Access to the specified native messaging host is forbidden.
- Is the extension’s origin listed in
allowed_origins
?
- Is the extension’s origin listed in
- Error when communicating with the native messaging host.
- This is a very common error and indicates an incorrect implementation of the communication protocol in the native messaging host.
- Make sure that all output in
stdout
adheres to the native messaging protocol. If you want to print some data for debugging purposes, write tostderr
. - Make sure that the 32-bit message length is in the platform’s native integer format (little-endian / big-endian).
- The message length must not exceed 1024*1024.
- The message size must be equal to the number of bytes in the message. This may differ from the «length» of a string, because characters may be represented by multiple bytes.
- Windows-only: Make sure that the program’s I/O mode is set to
O_BINARY
. By default, the I/O mode isO_TEXT
, which corrupts the message format as line breaks (n
=0A
) are replaced with Windows-style line endings (rn
=0D 0A
). The I/O mode can be set using__setmode
.
- Make sure that all output in
- This is a very common error and indicates an incorrect implementation of the communication protocol in the native messaging host.
VoimiX |
|
Статус: Активный участник Группы: Участники Сказал(а) «Спасибо»: 2 раз |
Автор: cross Автор: VoimiX Автор: ve2 Не уверен, что в эту ветку, но обнаружилась эта проблема при тестировании нового плагина. var oStore = yield cadesplugin.CreateObjectAsync(«CAPICOM.store»); если нет ни одного сертификата при получении списка происходит исключение Но в Explorer, при использовании объекта ActiveXObject(«CAPICOM.store»), В новой версии плагина это проблема до сих пор не исправлена. С последней версией var certCnt = yield certs.Count возвращает 0 при пустом списке. Скачал и установил новую версию. Теперь Версия плагина: 2.0.12234 Версия CSP: 3.6.7491 Но по прежнему НЕ работает. Причём я сэмулировал проблему на вашей тестовой странице https://www.cryptopro.ru…nc_cades_bes_sample.html Я в хроме у элемента option изменил value на несуществующий и нажал кнопку Подписать. |
|
|
spider |
|
Статус: Активный участник Группы: Участники Сказал «Спасибо»: 4 раз |
Автор: Смирнов Автор: spider Во вложении. Пока непонятно. Пришлите, пожалуйста, дамп вместе с логом JS-консоли от background page. Для сбора этого лога на странице chrome://extensions/ включите «Режим разработчика», и для нашего расширения нажмите «фоновая страница». Лог во вложении. Цитата: Disconnect Event: Error when communicating with the native messaging host. tabid a3b65a99-f0c8-3edc-6cc6-f25f3cbe5052 |
|
WWW |
cross |
|
Статус: Сотрудник Группы: Администраторы, Участники Сказал(а) «Спасибо»: 3 раз |
Автор: spider Автор: Смирнов Автор: spider Во вложении. Пока непонятно. Пришлите, пожалуйста, дамп вместе с логом JS-консоли от background page. Для сбора этого лога на странице chrome://extensions/ включите «Режим разработчика», и для нашего расширения нажмите «фоновая страница». Лог во вложении. Цитата: Disconnect Event: Error when communicating with the native messaging host. tabid a3b65a99-f0c8-3edc-6cc6-f25f3cbe5052 Ошибку воспроизвели и в скором времени исправим. Спасибо за найденный баг. PS: Доступ с тестового сервиса можно убирать. |
Техническую поддержку оказываем тут. |
|
|
|
idb |
|
Статус: Участник Группы: Участники Сказал(а) «Спасибо»: 1 раз |
А что по поводу функции Export? |
|
|
spider |
|
Статус: Активный участник Группы: Участники Сказал «Спасибо»: 4 раз |
Автор: cross Автор: spider Автор: Смирнов Автор: spider Во вложении. Пока непонятно. Пришлите, пожалуйста, дамп вместе с логом JS-консоли от background page. Для сбора этого лога на странице chrome://extensions/ включите «Режим разработчика», и для нашего расширения нажмите «фоновая страница». Лог во вложении. Цитата: Disconnect Event: Error when communicating with the native messaging host. tabid a3b65a99-f0c8-3edc-6cc6-f25f3cbe5052 Ошибку воспроизвели и в скором времени исправим. Спасибо за найденный баг. PS: Доступ с тестового сервиса можно убирать. Спасибо, ждем. |
|
WWW |
cross |
|
Статус: Сотрудник Группы: Администраторы, Участники Сказал(а) «Спасибо»: 3 раз |
Автор: idb А что по поводу функции Export? У нас не разу не воспроизвелось. Но с ним может быть такая же беда как и у spider. Нужно будет попробовать с следующей версией. |
Техническую поддержку оказываем тут. |
|
|
|
idb |
|
Статус: Участник Группы: Участники Сказал(а) «Спасибо»: 1 раз |
Тогда поддерживаю spider, ждем. Если поможет, то синхронный вариант Export работает. Отредактировано пользователем 2 сентября 2015 г. 17:30:28(UTC) |
|
|
cross |
|
Статус: Сотрудник Группы: Администраторы, Участники Сказал(а) «Спасибо»: 3 раз |
Обновили плагин с исправленной ошибкой падения плагина при использовании данных определенной длины. Отредактировано пользователем 2 сентября 2015 г. 18:03:09(UTC) |
Техническую поддержку оказываем тут. |
|
|
|
idb |
|
Статус: Участник Группы: Участники Сказал(а) «Спасибо»: 1 раз |
Обнаружил еще момент, если использовать cadesplugin_api в браузере с NPAPI, |
|
|
idb |
|
Статус: Участник Группы: Участники Сказал(а) «Спасибо»: 1 раз |
Автор: cross Обновили плагин с исправленной ошибкой падения плагина при использовании данных определенной длины. что то плагин не скачивается — error 404. |
|
|
Пользователи, просматривающие эту тему |
Guest |
Быстрый переход
Вы не можете создавать новые темы в этом форуме.
Вы не можете отвечать в этом форуме.
Вы не можете удалять Ваши сообщения в этом форуме.
Вы не можете редактировать Ваши сообщения в этом форуме.
Вы не можете создавать опросы в этом форуме.
Вы не можете голосовать в этом форуме.