Self-Hosted Error in BotController.php

Hello.
I am currently setting up my self-hosted instance and getting an error when trying to use the search box in the top right corner of the window.

[2020-03-28 16:23:10] production.ERROR: ErrorException [0] : /var/www/html/invoiceninja/app/Http/Controllers/BotController.php [Line 167] => file_get_contents(https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/ea1cda29-5994-47c4-8c25-2b58ae7ae7a8?subscription-key=&verbose=true&q=invoice): failed to open stream: HTTP request failed! HTTP/1.1 401 PermissionDenied {“context”:“PHP”,“user_id”:1,“account_id”:1,“user_name”:“user”,“method”:“POST”,“user_agent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0”,“locale”:“en”,“ip”:“x.x.x.x”,“count”:3,“is_console”:“no”,“is_api”:“no”,“db_server”:“mysql”,“url”:“handle_command”} []

Everything else seems to work properly.

From the error it looks like the voice command feature is failing, not sure why…

Thanks for responding.

If you follow the Microsoft link you get this message:

{"error":{"code":"401","message":"Access denied due to invalid subscription key or wrong API endpoint. Make sure to provide a valid key for an active subscription and use a correct regional API endpoint for your resource."}}

I don’t understand how the search feature works. It uses a Microsoft search?
I only typed in a word or invoice number in the box and got the error.

Does this feature require my own Microsoft subscription key?

Are there any config file options that can be changed for the search behavior or provider?

These are two different things, there is a basic search feature and you can optionally enable voice commands.

Is it possible you’ve enabled this in the .env file?

Okay here is my .env with private info hidden:

APP_ENV=production
APP_DEBUG=false
APP_LOCALE=en
APP_URL=https://invoice.example.com
APP_KEY=key
APP_CIPHER=AES-256-CBC
REQUIRE_HTTPS=true
DB_TYPE=mysql
DB_HOST=localhost
DB_DATABASE=invoiceninja
DB_USERNAME=invoiceninjauser
DB_PASSWORD=password
MAIL_DRIVER=smtp
MAIL_PORT=587
MAIL_ENCRYPTION=tls
MAIL_HOST=mail.example.com
MAIL_USERNAME=alert@example.com
MAIL_FROM_NAME='Alert'
MAIL_FROM_ADDRESS=alert@example.com
MAIL_PASSWORD=password
PHANTOMJS_CLOUD_KEY=a-demo-key-with-low-quota-per-ip-address
PHANTOMJS_SECRET=key
MAILGUN_DOMAIN=
MAILGUN_SECRET=
GOOGLE_MAPS_ENABLED=false
SESSION_ENCRYPT=true
SESSION_SECURE=true

See anything that would cause it?

Sorry I do not, have you tried a different browser?

Okay I just tried in Chrome, IE and Edge as well and also from another PC at another location and got the same result.
The errors in laravel-error.log are basically the same aside from the browser info.

I also added SPEECH_ENABLED=false to .env (and restarted Apache) but this made no difference.

Any other suggestions?

I can’t reproduce the problem to test, but… try commenting out this line of code:

https://github.com/invoiceninja/invoiceninja/blob/master/resources/views/header.blade.php#L355

Okay that did fix the error.
It moved the search box left just after the logo.
Also, when you search you need to press enter then the box moves down a line before displaying the drop down of results.
After moving down it will do a “live” search while typing.

Sorry, I’m not sure

Okay well thank you for helping and the quick responses!

Hillel,
After experimenting a bit more with this I realized the search does function normally (with the default header.blade.php) if I wait about 10 seconds after starting to type in the box.

I have imported about 10k clients into Invoice Ninja.

Could this just be a performance issue with the database?

Is there anything I can do to speed it up?

Thanks for the info, that could explain it.

The current version of the app isn’t optimised for such a large client list, the next version of the app should hopefully perform better.