I have a working Shiny App that queries a remote MySQL database via pool that I can run on my local machine.
The MySQL server has whitelisted shinyapps.io IP addresses.
When I deploy it to shinyapps.io, I get this error:
.global
library(shiny)
library(DBI)
library(pool)
library(DT)
pool <- dbPool(
drv = RMySQL::MySQL(),
dbname = "gw_observatory",
host = "sage.metro.ucdavis.edu",
username = "gw_observatory",
password = "password"
)
onStop(function() {
poolClose(pool)
})
.server
shinyServer(function(input, output, session) {
output$data_table <- renderDataTable({
DT::datatable(pool %>% tbl("small_data") %>% collect())
})
.ui
shinyUI(
fluidPage(
mainPanel(DT::dataTableOutput("data_table"))
)
)
UPDATE: It works now. My system admin added a port, and that fixed the issue.
For anyone down the line that is running into this issue, there are the steps I recommend:
make sure your shinyapp works locally
if you get deployment errors on shinyapps.io, make sure:
your database has whitelisted shinyappsio IP addresses
your host is an external, public IP or URL and not an internal one
some institutions have very guarded firewalls. Try adding a port to your database.
I hope this helps someone down the line!
pool <- dbPool(
drv = RMySQL::MySQL(),
dbname = "some_name",
host = "123.45.678.901",
username = "some_username",
password = "password",
port = 1234567
)
Related
I'm trying to get an AWS/Lightsail Debian server automatically renewing certificates with certbot. My DNS is with Namecheap.
I'm follow the steps on https://blog.bryanroessler.com/2019-02-09-automatic-certbot-namecheap-acme-dns/ and https://blog.bryanroessler.com/2019-02-09-automatic-certbot-namecheap-acme-dns/. I keep getting a no-permission error.
I run:
sudo certbot certonly -d "*.example.com" --agree-tos --manual-public-ip-logging-ok --server https://acme-v02.api.letsencrypt.org/directory --preferred-challenges dns --manual --manual-auth-hook /etc/letsencrypt/acme-dns-auth.py --debug-challenges
I see:
Failed authorization procedure. example.com (dns-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: No TXT record found at _acme-challenge.example.com
It says I need to open port 53. I followed Amazon's Lightsail instructions. Neither iptables nor ufw seems to be installed. When I nmap my machine, I don't see 53. I actually installed ufw for lack of a good idea, to no avail.
My /etc/acme-dns/config.cfg is as follows:
#/etc/acme-dns/config.cfg
[general]
# DNS interface
listen = ":53"
protocol = "udp"
# domain name to serve the requests off of
domain = "acme.example.com"
# zone name server
nsname = "ns1.acme.example.com"
# admin email address, where # is substituted with .
nsadmin = "example.example.com"
# predefined records served in addition to the TXT
records = [
"acme.example.com. A <public ip>",
"ns1.acme.example.com. A <public ip>",
"acme.example.com. NS ns1.acme.example.com.",
]
debug = false
[database]
engine = "sqlite3"
connection = "/var/lib/acme-dns/acme-dns.db"
[api]
api_domain = ""
ip = "127.0.0.1"
disable_registration = false
autocert_port = "80"
port = "8082"
tls = "none"
corsorigins = [
"*"
]
use_header = false
header_name = "X-Forwarded-For"
[logconfig]
loglevel = "debug"
logtype = "stdout"
logformat = "text"
For the listen value, I also tried 127.0.0.1:53 and :53
The settings portion of /etc/letsencrypt/acme-dns-auth.py:
# URL to acme-dns instance
ACMEDNS_URL = "http://127.0.0.1:8082"
# Path for acme-dns credential storage
STORAGE_PATH = "/etc/letsencrypt/acmedns.json"
# Whitelist for address ranges to allow the updates from
# Example: ALLOW_FROM = ["192.168.10.0/24", "::1/128"]
ALLOW_FROM = []
# Force re-registration. Overwrites the already existing acme-dns accounts.
FORCE_REGISTER = False
Thanks for any help you can provide.
If you don't wish to maintain your own acme DNS server, I built and use this script to automatically renew NameCheap wildcard certs with certbot. I hope it helps:
https://github.com/scribe777/letsencrypt-namecheap-dns-auth
I want to launch a shiny application from a terminal to avoid blocking the rstudio console.
My application uses the ssh package to connect to a remote machine.
When I launch the application from rstudio a small window opens to ask me for my password but when I launch the application from the terminal i get an error message.
$ "Rscript.exe" -e "shiny::runApp('app')"
Loading required package: shiny
Warning: package 'shiny' was built under R version 3.5.3
Warning: package 'ssh' was built under R version 3.5.3
Linking to libssh v0.8.6
Password callback did not return a string value
Erreur : Authentication with ssh server failed
Stopped
app.R
library(shiny)
library(ssh)
ssh.session <- ssh::ssh_connect(host = host)
cat("*** Logging in of the session ***")
# Define UI for application that draws a histogram
ui <- fluidPage()
server <- function(input, output) {
onStop(function() {
ssh_disconnect(ssh.session)
cat("*** Logging out of the session ***")
})
}
# Run the application
shinyApp(ui = ui, server = server)
I don't know about your security necessity in your use case...
What you could'd do (if its ok for you to specify a password while calling Rscript), is giving the password as an extra parameter when calling RScript and then forwarding it to ssh_connect(). You could also do the same with host variable. Im calling this R file via:
Rscript --vanilla home/user/R/app.R "password"
I'm not running shiny::runApp, because the line shinyApp(ui=ui, server=server) will automatically start up the shiny application, allowing us to connect to ssh beforehand.
In the app.R file we forward the arguments to ssh_connect.
app.R
library(shiny)
library(ssh)
args <- commandArgs(trailingOnly = TRUE)
host="host"
ssh.session <- ssh::ssh_connect(host = host,passwd = )
cat("*** Logging in of the session ***")
# Define UI for application that draws a histogram
ui <- fluidPage()
server <- function(input, output) {
onStop(function() {
ssh_disconnect(ssh.session)
cat("*** Logging out of the session ***")
})
}
# Run the application
shinyApp(ui = ui, server = server)
I’m using pyVmomi to deploy a VM from a template on vSphere,
this woks ok, the new VM get the name I sent as parameter but I want that the DNS name \ hostname will be same as VM.
Is there a way to set the hostname when doing the actual clone ?
If not how can I do that after the new VM was created ?
Here is part of the code I'm using:
# RelocateSpec
relospec = vim.vm.RelocateSpec()
relospec.datastore = datastore
relospec.pool = resource_pool
# ConfigSpec
configSpec = vim.vm.ConfigSpec()
configSpec.annotation = "This is the annotation for this VM"
# CloneSpec
clonespec = vim.vm.CloneSpec()
clonespec.location = relospec
clonespec.powerOn = power_on
clonespec.config = configSpec
print ("cloning VM...")
task = template.Clone(folder=destfolder, name=vm_name, spec=clonespec)
wait_for_task(task)
I think you need a clonespec.customization (vim.vm.customization.Specification). You should be able to specify the hostname there somehow or other.
Oh, as far as I know VMware Tools must be installed for guest OS customization.
Hope that helps.
I’ve created a connection to Db2 Warehouse on Cloud: dashDB for Analytics-t1 / Database: BLUDB. I’ve given ‘dashdb connect’ as the connection name.
Then I've selected Tools / RStudio. In RStudio, I've run the following lines. The error message below.
Code snippet:
library(ibmdbR)
con <- idaConnect('BLUDB','','')
#Close the connection
idaClose(con)
Output:
con <- idaConnect('BLUDB','','')
Warning messages:
1: In RODBC::odbcDriverConnect("DSN=BLUDB", believeNRows = FALSE) : [RODBC] ERROR: state 08001, code -30082, message [unixODBC][IBM][CLI Driver] SQL30082N Security processing failed with reason "17" ("UNSUPPORTED FUNCTION"). SQLSTATE=08001
2: In RODBC::odbcDriverConnect("DSN=BLUDB", believeNRows = FALSE) : ODBC connection failed
Your code snippet will only work as is if you run it in the RStudio from the DB2 Warehouse console. If you launch RStudio within DSX you need to configure connectivity. The following worked for me:
install.packages("ibmdbR")
library(ibmdbR)
dsn_driver <- "BLUDB"
dsn_database <- "BLUDB"
dsn_hostname <- "..."
dsn_port <- "50000"
dsn_protocol <- "TCPIP"
dsn_uid <- "..."
dsn_pwd <- "..."
con_path <- paste(dsn_driver,";DATABASE=",dsn_database,";HOSTNAME=",dsn_hostname,";PORT=",dsn_port,";PROTOCOL=",dsn_protocol,";UID=",dsn_uid,";PWD=",dsn_pwd,sep="")
ch <-idaConnect(con_path)
idaInit(ch)
idaShowTables()
Replace "..." with your credentials and you should be good to go.
I followed the instructions from the video named "Connect to dashDB in RStudio" on this page: https://datascience.ibm.com/docs/content/analyze-data/rstudio-overview.html and found the following documentation: https://datascience.ibm.com/blog/dashdb-r-dsx/
I'm using the following project for enabling APNS in my project:
https://github.com/stephenmuss/django-ios-notifications
I'm able to send and receive push notifications on my production app fine, but the sandbox apns is having strange issues which i'm not able to solve. It's constantly not connecting to the push service. When I do manually the _connect() on the APNService or FeedbackService classes, I get the following error:
File "/Users/MyUser/git/prod/django/ios_notifications/models.py", line 56, in _connect
self.connection.do_handshake()
Error: [('SSL routines', 'SSL3_READ_BYTES', 'sslv3 alert handshake failure')]
I tried recreating the APN certificate a number of times and constantly get the same error. Is there anything else i'm missing?
I'm using the endpoints gateway.push.apple.com and gateway.sandbox.push.apple.com for connecting to the service. Is there anything else I should look into for this? I have read the following:
Apns php error "Failed to connect to APNS: 110 Connection timed out."
Converting PKCS#12 certificate into PEM using OpenSSL
Error Using PHP for iPhone APNS
Turns out Apple changed ssl context from SSL3 to TLSv1 in development. They will do this in Production eventually (not sure when). The following link shows my pull request which was accepted into the above project:
https://github.com/stephenmuss/django-ios-notifications/commit/879d589c032b935ab2921b099fd3286440bc174e
Basically, use OpenSSL.SSL.TLSv1_METHOD if you're using python or something similar in other languages.
Although OpenSSL.SSL.SSLv3_METHOD works in production, it may not work in the near future. OpenSSL.SSL.TLSv1_METHOD works in production and development.
UPDATE
Apple will remove SSL 3.0 support in production on October 29th, 2014 due to the poodle flaw.
https://developer.apple.com/news/?id=10222014a
I have worked on APN using python-django, for this you need three things URL, PORT and Certificate provided by Apple for authentication.
views.py
import socket, ssl, json, struct
theCertfile = '/tmp/abc.cert' ## absolute path where certificate file is placed.
ios_url = 'gateway.push.apple.com'
ios_port = 2195
deviceToken = '3234t54tgwg34g' ## ios device token to which you want to send notification
def ios_push(msg, theCertfile, ios_url, ios_port, deviceToken):
thePayLoad = {
'aps': {
'alert':msg,
'sound':'default',
'badge':0,
},
}
theHost = ( ios_url, ios_port )
data = json.dumps( thePayLoad )
deviceToken = deviceToken.replace(' ','')
byteToken = deviceToken.decode('hex') # Python 2
theFormat = '!BH32sH%ds' % len(data)
theNotification = struct.pack( theFormat, 0, 32, byteToken, len(data), data )
# Create our connection using the certfile saved locally
ssl_sock = ssl.wrap_socket( socket.socket( socket.AF_INET, socket.SOCK_STREAM ), certfile = theCertfile )
ssl_sock.connect( theHost )
# Write out our data
ssl_sock.write( theNotification )
# Close the connection -- apple would prefer that we keep
# a connection open and push data as needed.
ssl_sock.close()
Hopefully this would work for you.