• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
pifreak

MySQL Database - Frustrating connection problems

7 posts in this topic

Hello fellow developers,

I have searched the topics and not found what I need so I'm making this post.
I have made an online RPG game that uses MySQL for a database.

Everything works fine. Transactiosn are solid. Upon losing connections it reconnects fine.
I've had an experienced programmer friend look over the code and he says it looks correct.

The problem is, why does the program disconnect form MySQL? It happens often if it is connecting to a remote database, however right now it's connecting to a local database. I do not really know much about MySQL config or how to do it properly.

There are conflicting opinions and suggestions across the web...

[b]Server Setup:[/b]
Amazon EC2 Small (Default) instance 1.7GB ram
Linux Server distro - Ubuntu Server 12.04 LTS

[b]Game Server:[/b]
C++ native Linux program powered by the MySQL C API.


[b]MySQL Setup:[/b]
[CODE]
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 10.190.89.159
#
# * Fine Tuning
#
key_buffer = 64M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit = 128M
query_cache_size = 64M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
#
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
#
# Here you can see queries with especially long duration
#log_slow_queries = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 7
max_binlog_size = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem

[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
#no-auto-rehash # faster start of mysql but no tab completition
[isamchk]
key_buffer = 16M
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
[/CODE]

The disconnects print out errors such as:
"Lost connection to MySQL Server during query!"
"The MySQL Server has gone away!"

This issue is not urgent but I do not quite understand why it would disconnect from a local database. And I do appreciate the help if anyone wishes to. :)


Thank you so much!

pi`
0

Share this post


Link to post
Share on other sites
First, be very careful about your data on the ECC. An instance may just go away, and if your database was running on local disk on that isntance, it's forever gone. ECC has two other options to solve this: Elastic Block Store, or the Relational Database Service.

Second, MySQL will disconnect if there is a network problem, or if a connection stays idle for too long.
0

Share this post


Link to post
Share on other sites
The server is running on an EBS volume, so everything's safe.
There isn't a network problem because it's connecting to localhost.
The connection is not idle too long. There is a query every 5 minutes and frequent pings to check if the connection is alive.

Is something configured wrong in the my.cnf you see above?


pi` Edited by pifreak
0

Share this post


Link to post
Share on other sites
Is the code you're writing for the client, or your server program that needs to store persistant data in the DB? If it's the server, and the server is going to be on a different machine than the DB, is the DB configured to allow remote connections from the server's machine? If it's the client, slap yourself on the wrist and rethink your architecture because you're going to get hacked otherwise.
0

Share this post


Link to post
Share on other sites
The server. Like I said, it's connecting locally.
When I mentioned connecting remotely disconnecting more often, I meant running the server on my workstation ----> connect to Amazon EC2 database being remote.

I just don't get why it keeps losing connection during a query...

pi`
0

Share this post


Link to post
Share on other sites
[quote]I just don't get why it keeps losing connection during a query...[/quote]

Use WireShark and catch it in the act!
0

Share this post


Link to post
Share on other sites
[quote]Use wireshark on a command line linux server?
[/quote]

Use tcpdump to generate a pcap file, and then analyze with Wireshark on another box.
Or just use tcpdump in display mode.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0