Cannot connect Strongloop / Loopback datasource to a SQL Server Express database - sql-server

Within a newly created loopback framework running slc arc I am attempting to connect to an existing SQL Server Express database at ALEX\SQLEXPRESS (I've also tried variations like LOCALHOST\SQLEXPRESS).
But I am getting the error message:
Oops! Something is wrong
Failed to connect to ALEX:undefined in 15000ms
I've also tried ALEX\\SQLEXPRESS since it looks like the undefined might be caused by the slash.
Unfortunately no luck. Does anyone know how to make this work?
These are the settings
This is the connector that gets created in the folders:
{
"db": {
"name": "db",
"connector": "memory"
},
"mssql": {
"host": "ALEX\\SQLEXPRESS",
"database": "bbdb-dev",
"password": "********",
"name": "mssql",
"user": "sa",
"connector": "mssql"
}
}

It appears that the SQL server must be configured correctly I used these instructions http://blog.citrix24.com/configure-sql-express-to-accept-remote-connections/ and then connected via IP address instead of a named connection with a slash in it.

Make sure that SQL server is configured correctly.
Install connector globally sudo npm install loopback-connector-mssql -g
Give in the credentials in Arc. refer screen-shot to see how I've connected
Hope it helps! Works for me :)

Related

Setting up VSCode with xdebug: pathMapping

I am trying to set up debugging in VSCode and have run into a bit of a challenge. I typed the path to the localSourceRoot but Intellisense is telling me that it is deprecated and I should use pathMapping instead.
I am a newbie and don't know how to properly set that up. If someone could explain to me the variables and/or attributes pathMapping is requesting I would be forever in your debt.
My system info is as follows:
PHP version: 5.524
xdebug version: 2.2.5
OS Windows 8.1
Using Desktop Server version: 3.8.5
I checked the phpinfo() and it shows Xdebug in the file so I know that it is installed. The launch.json file is pretty basic with port 9000 and all of that. I just need to get that darned pathMapping thing done.
Thanks for any and all help.
I guess you're using the PHP debug extension ?
https://github.com/felixfbecker/vscode-php-debug
The README.md says the following:
Remote Host Debugging
To debug a running application on a remote host, you need to tell XDebug to connect to a different IP than localhost. This can either be done by setting xdebug.remote_host to your IP or by setting xdebug.remote_connect_back = 1 to make XDebug always connect back to the machine who did the web request. The latter is the only setting that supports multiple users debugging the same server and "just works" for web projects. Again, please see the XDebug documentation on the subject for more information.
To make VS Code map the files on the server to the right files on your local machine, you have to set the pathMappings settings in your launch.json. Example:
// server -> local
"pathMappings": {
"/var/www/html": "${workspaceRoot}/www",
"/app": "${workspaceRoot}/app"
}
Please also note that setting any of the CLI debugging options will not work with remote host debugging, because the script is always launched locally. If you want to debug a CLI script on a remote host, you need to launch it manually from the command line.
Thus is as much a reference to myself as well as others who might find this helpful. I am running VSCODE with xdebug and drupalvm and the following works for me after setting the following in php.ini
php_xdebug_idekey: VSCODE
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"pathMappings": {
"/var/www/drupalvm/drupal": "${workspaceRoot}/drupal",
},
"log": true
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}

"Invalid Host header" when web app is served inside a VM (Angular2CLI)

I am trying to run my web app from inside an Ubuntu 16 64-bit virtual machine. Of course, this means I can't have the host be localhost, so I changed the host in the .angular-cli.json file under defaults:
"defaults": {
"serve": {
"host": "0.0.0.0"
},
"styleExt": "css",
"component": {}
}
When I do npm start and go to the URL of the VM, I get a page saying "Invalid Host header". What am I doing wrong? How can I run the web app and access it correctly?
I am new to Angular and was following this tutorial: https://angular.io/guide/quickstart. I am also using Vagrant.
Any help would be appreciated, thank you!
It turns out I had to use the private_network ip address as the host instead, which is located inside the Vagrantfile on this line:
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "192.168.100.5"
Though, this only makes it work locally. If someone else has an answer, it would be greatly appreciated!
host should be 192.168.0.100 (your ubuntu server ip).
maybe you can just edit package.json
add host para in start cmd.
"start": "************* --host 192.168.0.100 ",
and npm start will be ok.

Connecting Phoenix app to MS SQL Azure database

I am trying to connect a phoenix application to MS SQL. After looking around online I came across a couple of adapters called mssql_ecto & mssqlex.
I have added them to the project following the instructions in the readme, installed odbc and checked that the db is online but I am now getting the following error..
[error] Mssqlex.Protocol (#PID<0.13069.0>) failed to connect: ** (Mssqlex.Error) odbc_not_started
My app is configured as below..
config :my_app, MyApp.Repo,
adapter: MssqlEcto,
username: "<my_username>",
password: "<my_password>",
database: "test",
hostname: "<my_server>.database.windows.net",
pool_size: 10
My environment is as follows..
MacOS Sierra 10.12.5
Elixir version: 1.4.4
There is an issue in the mssql_ecto repo already, and I have tried the suggestions from there, but it still has not worked.
If anyone has managed to connect their phoenix/elixir application to MSSQL on macOS and could provide some instructions it would be greatly appreciated (even if it was done in a completely different way to my approach 😉 ).
Side note: Tried it in node with the same db and was able to connect to and query the db.
I've been working through the same issue this week, connecting to an Azure SQL Database, and this is what I've got working.
You are seeing the first of 2 main problems I ran into:
Erlang installed without ODBC
Mssqlex adapter is missing required configuration options
#1: Erlang installed without ODBC
If you've installed Elixir and Erlang using brew, or something like it, you are getting an installation of Erlang that does not include erlang-odbc. In order to remedy this, you will need to install Erlang from source.
I recommend that you install both Erlang and Elixir from source using the method documented here:
http://www.lambdacat.com/how-to-install-elixir-on-mac/
Just make sure that you remove the Kerl option, --without-odbc, before you build Erlang.
Now that you have Erlang installed correctly, the odbc_not_started error should go away... to be replaced by connection errors to the database.
#2: Mssqlex adapter is missing required configuration options
As of this moment, the mssqlex adapter does not support the following configuration options that Azure is looking for:
Encrypt
TrustServerCertificate
Connection Timeout
To get around this issue, I forked the mssqlex library and added those options in a branch. I am not committing to maintaining this so feel free to fork it yourself.
In order to use the modified mssqlex, replace the mix dependency with the github location and branch name:
{:mssqlex, git: "https://github.com/tvanhouten/mssqlex.git", branch: "azure-settings", override: true}
The override: true is important because mssql_ecto has a dependency on the mssqlex version in hex.
Now you can update your configuration:
config :my_app, MyApp.Repo,
adapter: MssqlEcto,
username: "<my_username>",
password: "<my_password>",
database: "test",
hostname: "<my_server>.database.windows.net",
pool_size: 10,
encrypt: "yes",
trust_server_certificate: "no",
connection_timeout: "30
Other "Gotchas" to Look Out For
Azure requires TCP connection:
In order to connect to an Azure SQL Database, you will need to make sure that the hostname: option starts with tcp:. So, all together, it will look like
hostname: "tcp:.database.windows.net"
Mssql_ecto does not support Ecto 2.2+:
If you're getting errors related to Ecto or Ecto.SubQuery, you probably need to make sure that you are using a version of Ecto that is supported by mssql_ecto. At this point in time, that means Ecto 2.1.x. Again, this requires a slight change to your mix dependencies:
{:ecto, ">= 2.1.0 and < 2.2.0"}
Dependency cache and lock issues:
If everything seems to be in order according to the above but it just doesn't seem like the new dependencies are being updated and compiled as expected, do the following:
Run mix deps.clean --all
Delete the mix.lock file from your root project directory
Run mix deps.get
Run mix deps.compile
That should do it!

could not connect to local host

Recently i installed apache tomcat 6 on my PC.I started the server and try to open the tomcat manager using the url:
http://localhost:8081/manager/html
8081 is the connector port i used at the time of installation and no other services using this port.But its shows the error like
Oops! Google Chrome could not connect to localhost:8081
I used this with differnt browsers IE and crome but still getting the same error
Please provide me the solving to getrid of this.
Try the "Test your Install" section here.
first make sure the your server is running correctly by connect to http://localhost:8081/

How can I debug a PHP CLI script with xdebug?

I haven't quite figured this out. EVERY piece of documentation I've found covers how to use xdebug to debug scripts running in Apache. I need to debug a php CLI script.
So, for instance, how do I pass the XDEBUG_SESSION_START variable in to get xdebug to kick on?
I'm specifically trying to debug a CakePHP shell. So if anyone has any additional insight into that I'd be very appreciative.
Thanks.
There is a couple of notes about that in Xdebug's manual, like, for instance (quoting) :
export XDEBUG_CONFIG="idekey=session_name"
php myscript.php
If you are using Eclipse PDT to develop and debug your PHP scripts, there is not much difference between Apache or CLI : the configuration lloks quite the same, you just don't have to configure a web server, nor indicate an URL ; instead, you have to indicate the path to the PHP executable.
About the XDEBUG_SESSION_START variable : well, you launch the whole script in "debug-mode", so you don't have any notion of "debugging-session", I'd say.
For instance, here's what Window > Preference > PHP > PHP executables looks like for me right now, and, on the right, what I get when clicking on the Edit button of the first one :
(source: pascal-martin.fr)
(source: pascal-martin.fr)
And the debug configurations window :
(source: pascal-martin.fr)
And launching the debugging: it just works :
(source: pascal-martin.fr)
Hope this helps :-)
Else, what specific problem do you encounter ?
If you're using bash (or similar shell), this little script might come in handy:
alias drush-debug=drd
function drd {
export XDEBUG_CONFIG="idekey=cli_session"
export SERVER_NAME="developer.machine"
export SERVER_PORT="9000"
drush "$#"
unset XDEBUG_CONFIG
unset SERVER_NAME
unset SERVER_PORT
};
or as suggested by the commentators below
alias drd='XDEBUG_CONFIG="idekey=PHPSTORM" drush "$#"'
This way you don't have to manually set and unset the trigger variable each time you want to debug.
simply put the following section to your php.ini
[XDebug]
xdebug.max_nesting_level = 200
xdebug.remote_enable=1
xdebug.remote_port=9000
;xdebug.profiler_enable=1
xdebug.idekey=PHPSTORM
xdebug.remote_autostart=1
and replace PHPSTORM with your ide key
For Windows and Visual Studio Code here's how to proceed:
Download xdebug from https://xdebug.org/download. For example php 7.4 Windows 64bit https://xdebug.org/files/php_xdebug-2.9.5-7.4-vc15-nts-x86_64.dll
Copy the xdebug dll to your php extensions dir (ext).
Add to the end of php.ini
[XDebug]
zend_extension=php_xdebug-2.9.5-7.4-vc15-nts-x86_64.dll
xdebug.remote_enable=1
xdebug.remote_autostart=1
Open VSCode and install https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug
Open the project workspace in VSCode, go to Run tab, click the cogwheel and add these lines
{
"name": "listen CLI",
"type": "php",
"request": "launch",
"port": 9000
},
{
"name": "run CLI",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
Place a break point in the script you want to debug
Select "run CLI" and click "Start Debugging"
Happy debugging!
PHP configuration:
zend_extension=xdebug.so
xdebug.remote_handler=dbgp
xdebug.mode=debug
On my system it is file /etc/php/conf.d/xdebug.ini. Could be in the main php.ini too.
If I want to run a script with XDebug, I pass an environment variable inline:
XDEBUG_SESSION=1 php arguments

Resources