<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Socket on shocksolution.com</title><link>https://shocksolution.com/tags/socket/</link><description>Recent content in Socket on shocksolution.com</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Thu, 22 Apr 2021 18:54:25 +0000</lastBuildDate><atom:link href="https://shocksolution.com/tags/socket/index.xml" rel="self" type="application/rss+xml"/><item><title>Node.js: Connecting to MySQL on a socket with Sequelize</title><link>https://shocksolution.com/posts/node-js-connecting-to-mysql-on-a-socket-with-sequelize/</link><pubDate>Thu, 22 Apr 2021 18:54:25 +0000</pubDate><guid>https://shocksolution.com/posts/node-js-connecting-to-mysql-on-a-socket-with-sequelize/</guid><description>&lt;p&gt;According to its official description, &amp;ldquo;&lt;a href="https://sequelize.org/master/index.html"&gt;Sequelize is a promise-based Node.js ORM for Postgres, MySQL, MariaDB, SQLite and Microsoft SQL Server.&lt;/a&gt;&amp;rdquo; Sequelize is widely used in Node.js web applications to abstract the database layer. I recently found a &amp;ldquo;corner case&amp;rdquo; for Sequelize which is possible to accomplish, but is not well documented anywhere on the web. I need to use Sequelize to connect to a MySQL server via a UNIX socket. I&amp;rsquo;m developing some plugins for Confluence that use the &lt;a href="https://bitbucket.org/atlassian/atlassian-connect-express/src/master/"&gt;atlassian-connect-express&lt;/a&gt; toolkit, which has a datastore that wraps Sequelize. The way Atlassian has chosen to wrap Sequelize is rather unfortunate, probably because they are trying to maintain backwards compatibility with JugglingDB. Essentially, the Atlassian Connect Express only looks at the URL, and ignores any option passed to Sequelize. Therefore, you have to pass everything you need via the URL, and this is where it&amp;rsquo;s tricky. Here&amp;rsquo;s the form of the URL that you need to connect to MySQL via a UNIX socket with Sequelize:&lt;/p&gt;</description></item><item><title>Configuring Laravel/Lumen applications to connect to SQL database sockets</title><link>https://shocksolution.com/posts/configuring-laravel-lumen-applications-to-connect-to-sql-database-sockets/</link><pubDate>Mon, 14 May 2018 18:58:47 +0000</pubDate><guid>https://shocksolution.com/posts/configuring-laravel-lumen-applications-to-connect-to-sql-database-sockets/</guid><description>&lt;p&gt;The Laravel/Lumen framework documentation does not explain how to connect an application to a database using UNIX sockets instead of a TCP-based network connection. I recently had to configure the &lt;a href="https://polrproject.org/"&gt;Polr URL shortener&lt;/a&gt; (built on the &lt;a href="https://lumen.laravel.com/"&gt;Lumen microframework&lt;/a&gt; by &lt;a href="https://laravel.com/"&gt;Laravel&lt;/a&gt;) to connect to Google Cloud SQL with a UNIX socket. Since all of Polr&amp;rsquo;s configuration takes place in the &lt;strong&gt;.env&lt;/strong&gt; file, and there is no environment variable that&amp;rsquo;s specific to database sockets, this took some research. I finally found the answer in an &lt;a href="https://stackoverflow.com/questions/29305502/php-artisan-migrate-with-mamp-and-unix-socket/39509268#39509268"&gt;obscure StackOverflow response&lt;/a&gt;. Previous TCP connection: [code] DB_HOST=some-server-name DB_PORT=3306 [/code] Socket-based SQL connection: [code] DB_HOST=localhost;unix_socket=/cloudsql/cloud-project-name:us-east1:sql-instance-name [/code] This approach will work with any UNIX socket; you just need to give it the absolute path to the socket.&lt;/p&gt;</description></item></channel></rss>